-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
33 lines (29 loc) · 908 Bytes
/
main_test.go
File metadata and controls
33 lines (29 loc) · 908 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
package main
import "testing"
func TestRealMain(t *testing.T) {
var tests = []struct {
description string
schema string
args []string
success bool
}{
{"valid_schema_valid_document", "testdata/schema.yaml", []string{"testdata/valid.yaml"}, true},
{"valid_schema_invalid_document", "testdata/schema.yaml", []string{"testdata/invalid.yaml"}, false},
{"no_schema_valid_document", "", []string{"testdata/valid.yaml"}, true},
{"no_schema_invalid_document", "", []string{"testdata/broken.yaml"}, false},
{"no_input", "", []string{}, false},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
ret := realMain(test.schema, test.args)
success := ret == 0
if success != test.success {
expectation := "succeed"
if test.success == false {
expectation = "fail"
}
t.Errorf("test expected to %s", expectation)
}
})
}
}