diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-23 14:14:45 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-23 14:53:50 +0900 |
| commit | 75e0c5d4061d68dc4802285ec137e464f4e01b17 (patch) | |
| tree | b8307fa68188bac4c522afc36c27a5c1fb7c02da /test/sandbox/mount_test.go | |
| parent | 770b37ae166a18f495865e96ccafc6f9fb9f4e88 (diff) | |
test/sandbox: parse full test case
This makes declaring multiple tests much cleaner.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/sandbox/mount_test.go')
| -rw-r--r-- | test/sandbox/mount_test.go | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/test/sandbox/mount_test.go b/test/sandbox/mount_test.go index 47df2103..23a58fb1 100644 --- a/test/sandbox/mount_test.go +++ b/test/sandbox/mount_test.go @@ -92,27 +92,29 @@ overlay /.fortify/sbin/fortify overlay ro,nosuid,nodev,relatime,lowerdir=/mnt-ro } t.Run(tc.name, func(t *testing.T) { + f, err := sandbox.OpenMounts(name) + if err != nil { + t.Fatalf("OpenMounts: error = %v", err) + } + i := 0 - if err := sandbox.IterMounts(name, func(e *sandbox.Mntent) { + for e := range f.Entries() { if i == len(tc.want) { - t.Errorf("IterMounts: got more than %d entries", i) + t.Errorf("Entries: got more than %d entries", i) t.FailNow() } if *e != tc.want[i] { - t.Errorf("IterMounts: entry %d\n got: %s\nwant: %s", i, + t.Errorf("Entries: entry %d\n got: %s\nwant: %s", i, e, &tc.want[i]) t.FailNow() } + i++ - }); err != nil { - t.Fatalf("IterMounts: error = %v", err) } - }) - t.Run(tc.name+" assert", func(t *testing.T) { - oldFatal := sandbox.SwapFatal(t.Fatalf) - t.Cleanup(func() { sandbox.SwapFatal(oldFatal) }) - sandbox.MustAssertMounts(name, name, sandbox.MustWantFile(t, tc.want)) + if err = f.Err(); err != nil { + t.Fatalf("MountsFile: error = %v", err) + } }) if err := os.Remove(name); err != nil { |
