forked from coredns/corefile-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidversions_test.go
More file actions
37 lines (33 loc) · 1.07 KB
/
validversions_test.go
File metadata and controls
37 lines (33 loc) · 1.07 KB
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
package cmd
import (
"bytes"
"testing"
)
func TestNewValidVersionsCmd(t *testing.T) {
var buf bytes.Buffer
testCases := []struct {
name string
expectedOutput string
expectedError bool
}{
{
name: "Works without error",
expectedOutput: `The following are valid CoreDNS versions:
1.1.3, 1.1.4, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.9, 1.7.0, 1.7.1, 1.8.0, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.10.0, 1.10.1, 1.11.0, 1.11.1, 1.11.3, 1.11.4, 1.12.0, 1.12.1, 1.12.2, 1.12.3, 1.12.4. 1.13.0, 1.13.1, 1.13.2, 1.14.0, 1.14.1
`,
expectedError: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
cmd := NewValidVersionsCmd(&buf)
err := cmd.Execute()
if err != nil && !tc.expectedError {
t.Errorf("Cannot execute command: %v", err)
}
if buf.String() != tc.expectedOutput {
t.Errorf("Expected output %v did not match %v", buf.String(), tc.expectedOutput)
}
})
}
}