X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fconfig%2Ftemplates_test.go;h=3ed9bbfceda47e85d93314daf52342878b4409d5;hb=ba1a93368ed95d7160062f60fb8b579bc178d3aa;hp=8097af7312f3891ea2626f435ff4a3933d4cbcef;hpb=4299c5d0946ecfa034e9eefe6b16e50bab94a820;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/config/templates_test.go b/cmd/safcm/config/templates_test.go index 8097af7..3ed9bbf 100644 --- a/cmd/safcm/config/templates_test.go +++ b/cmd/safcm/config/templates_test.go @@ -19,12 +19,10 @@ import ( "fmt" "io/fs" "os" - "reflect" "testing" - "github.com/google/go-cmp/cmp" - "ruderich.org/simon/safcm" + "ruderich.org/simon/safcm/testutil" ) func TestLoadTemplates(t *testing.T) { @@ -32,7 +30,7 @@ func TestLoadTemplates(t *testing.T) { if err != nil { t.Fatal(err) } - defer os.Chdir(cwd) + defer os.Chdir(cwd) //nolint:errcheck err = os.Chdir("../testdata/project") if err != nil { @@ -99,6 +97,15 @@ func TestLoadTemplates(t *testing.T) { This is GNU/Linux host + + +all + + +host1.example.org + + + `), }, "/etc/rc.local": { @@ -252,14 +259,8 @@ This is GNU/Linux host err = LoadTemplates(tc.group, files, host, groups, allHosts, allGroups) - if !reflect.DeepEqual(tc.exp, files) { - t.Errorf("res: %s", cmp.Diff(tc.exp, files)) - } - // Ugly but the simplest way to compare errors (including nil) - if fmt.Sprintf("%s", err) != fmt.Sprintf("%s", tc.expErr) { - t.Errorf("err = %#v, want %#v", - err, tc.expErr) - } + testutil.AssertEqual(t, "res", files, tc.exp) + testutil.AssertErrorEqual(t, "err", err, tc.expErr) }) } }