mirror of
https://github.com/fluxcd/flux2.git
synced 2025-10-29 23:37:47 +08:00
tests: only provide template values when used
As otherwise the `.golden` values can not be automatically updated using `-update` as documented in `CONTRIBUTING.md`. Also ensure we do not use `defer` but rather `t.Cleanup` in tests, as this will always be called even if e.g. `t.Fatal` absruptly stops the test. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
@ -22,6 +22,13 @@ package main
|
||||
import "testing"
|
||||
|
||||
func TestImageScanning(t *testing.T) {
|
||||
namespace := allocateNamespace("tis")
|
||||
del, err := setupTestNamespace(namespace)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(del)
|
||||
|
||||
cases := []struct {
|
||||
args string
|
||||
goldenFile string
|
||||
@ -48,13 +55,6 @@ func TestImageScanning(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
namespace := allocateNamespace("tis")
|
||||
del, err := setupTestNamespace(namespace)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer del()
|
||||
|
||||
for _, tc := range cases {
|
||||
cmd := cmdTestCase{
|
||||
args: tc.args + " -n=" + namespace,
|
||||
|
||||
Reference in New Issue
Block a user