aboutsummaryrefslogtreecommitdiff
path: root/config/config_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-03-18 22:42:23 +0100
committerJulien Dessaux2021-03-18 22:42:39 +0100
commit179a6d2ca01902f35da1ece8804a515dfba0ea55 (patch)
treea8c9b455e8f691e684f9fd50f85f77248753ec3a /config/config_test.go
parentRemoved unused statement in tests (diff)
downloadshell-game-launcher-179a6d2ca01902f35da1ece8804a515dfba0ea55.tar.gz
shell-game-launcher-179a6d2ca01902f35da1ece8804a515dfba0ea55.tar.bz2
shell-game-launcher-179a6d2ca01902f35da1ece8804a515dfba0ea55.zip
Fixed possible nil dereference in tests
Diffstat (limited to 'config/config_test.go')
-rw-r--r--config/config_test.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/config/config_test.go b/config/config_test.go
index 5a1dd38..dfa8237 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -49,10 +49,13 @@ func TestLoadFile(t *testing.T) {
},
},
}
- if config, err := LoadFile("test_data/minimal.yaml"); err != nil || !reflect.DeepEqual(want, *config) {
- t.Fatalf("minimal example failed:\nerror %v\nwant:%+v\ngot: %+v", err, want, *config)
+ config, err := LoadFile("test_data/minimal.yaml")
+ if err != nil {
+ t.Fatalf("minimal example failed with error : %v", err)
+ }
+ if config != nil && !reflect.DeepEqual(want, *config) {
+ t.Fatalf("minimal example failed:\nwant:%+v\ngot: %+v", want, *config)
}
-
t.Cleanup(func() { os.RemoveAll("var/") })
// Invalid App
if _, err := LoadFile("test_data/invalid_app.yaml"); err == nil {
@@ -208,7 +211,11 @@ func TestLoadFile(t *testing.T) {
},
},
}
- if config, err := LoadFile("../example/complete.yaml"); err != nil || !reflect.DeepEqual(want, *config) {
- t.Fatalf("complete example failed:\nerror %v\nwant:%+v\ngot: %+v", err, want, *config)
+ config, err = LoadFile("../example/complete.yaml")
+ if err != nil {
+ t.Fatalf("complete example failed with error : %v", err)
+ }
+ if config != nil && !reflect.DeepEqual(want, *config) {
+ t.Fatalf("complete example failed:\nwant:%+v\ngot: %+v", want, *config)
}
}