X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fainsl%2Fainsl_test.go;h=8e9b0c121a268747d2a234dab0e1a045927fd55f;hb=5d6cc7f14a4bacc36bf3a23cd735a75ad4a90f1d;hp=564bc37d99fde46e81ebbe305d27ee838d59b5f1;hpb=4299c5d0946ecfa034e9eefe6b16e50bab94a820;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/ainsl/ainsl_test.go b/cmd/safcm-remote/ainsl/ainsl_test.go index 564bc37..8e9b0c1 100644 --- a/cmd/safcm-remote/ainsl/ainsl_test.go +++ b/cmd/safcm-remote/ainsl/ainsl_test.go @@ -20,13 +20,12 @@ import ( "io/fs" "os" "path/filepath" - "reflect" + "runtime" "syscall" "testing" - "github.com/google/go-cmp/cmp" - ft "ruderich.org/simon/safcm/cmd/safcm-remote/sync/filetest" + "ruderich.org/simon/safcm/testutil" ) func TestHandle(t *testing.T) { @@ -55,6 +54,12 @@ func TestHandle(t *testing.T) { } _, uid, _, gid := ft.CurrentUserAndGroup() + symlinkExists := "open file: too many levels of symbolic links" + if runtime.GOOS == "freebsd" { + // EMLINK instead of ELOOP + symlinkExists = "open file: too many links" + } + tests := []struct { name string path string @@ -270,7 +275,7 @@ func TestHandle(t *testing.T) { }, }, nil, - fmt.Errorf("open file: too many levels of symbolic links"), + fmt.Errorf(symlinkExists), }, { "exists: fifo", @@ -310,24 +315,15 @@ func TestHandle(t *testing.T) { } changes, err := handle(tc.path, tc.line, tc.create) - if !reflect.DeepEqual(tc.expChanges, changes) { - t.Errorf("changes: %s", - cmp.Diff(tc.expChanges, changes)) - } - // 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, "changes", + changes, tc.expChanges) + testutil.AssertErrorEqual(t, "err", err, tc.expErr) files, err := ft.WalkDir(path) if err != nil { t.Fatal(err) } - if !reflect.DeepEqual(tc.expFiles, files) { - t.Errorf("files: %s", - cmp.Diff(tc.expFiles, files)) - } + testutil.AssertEqual(t, "files", files, tc.expFiles) }) }