-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathversion_test.go
More file actions
42 lines (35 loc) · 971 Bytes
/
version_test.go
File metadata and controls
42 lines (35 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cmd
import (
"bytes"
"fmt"
"net/http"
"testing"
"github.com/arschles/assert"
"github.com/drycc/controller-sdk-go"
"github.com/drycc/workflow-cli/pkg/testutil"
"github.com/drycc/workflow-cli/version"
)
func TestVersion(t *testing.T) {
t.Parallel()
cf, server, err := testutil.NewTestServerAndClient()
if err != nil {
t.Fatal(err)
}
defer server.Close()
var b bytes.Buffer
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
server.Mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("DRYCC_API_VERSION", "1234")
w.WriteHeader(200)
})
err = cmdr.Version(true)
assert.NoErr(t, err)
assert.Equal(t, b.String(), fmt.Sprintf(`Workflow CLI Version: %s
Workflow CLI API Version: %s
Workflow Controller API Version: 1234
`, version.Version, drycc.APIVersion), "output")
b.Reset()
err = cmdr.Version(false)
assert.NoErr(t, err)
assert.Equal(t, b.String(), version.Version+"\n", "output")
}