File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,26 @@ func TestGenKey(t *testing.T) {
24
24
}
25
25
}
26
26
27
- func TestUnmarshalOutput (t * testing.T ) {
27
+ func TestUnmarshalOutputNormal (t * testing.T ) {
28
28
expected := "1.0"
29
29
testJSON := fmt .Sprintf (`{"APP_VERSION": "%s"}` , expected )
30
- result , err := unmarshalOutput (testJSON )
31
- if err != nil {
32
- t .Errorf ("TestUnmarshalOutput failed: %v" , err )
33
- }
30
+ result , _ := unmarshalOutput (testJSON )
34
31
if result .Version != expected {
35
32
t .Errorf ("expected %s; got %s\n " , expected , result .Version )
36
33
}
37
34
}
35
+
36
+ func TestUnmarshalOutputUnmarshalFailure (t * testing.T ) {
37
+ if _ , err := unmarshalOutput (`{test}` ); err == nil {
38
+ t .Error ("JSON unmarshalling should fail" )
39
+ }
40
+ }
41
+
42
+ func TestUnmarshalOutputNotJSONArray (t * testing.T ) {
43
+ defer func () {
44
+ if r := recover (); r == nil {
45
+ t .Error ("expected: runtime error: slice bounds out of range" )
46
+ }
47
+ }()
48
+ unmarshalOutput (`` )
49
+ }
You can’t perform that action at this time.
0 commit comments