diff options
Diffstat (limited to 'internal/pkg/pkg_test.go')
| -rw-r--r-- | internal/pkg/pkg_test.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index 6b5d5fc4..82f260e7 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -33,7 +33,7 @@ import ( func unsafeOpen( ctx context.Context, msg message.Msg, - cures int, + flags, cures int, base *check.Absolute, lock bool, ) (*pkg.Cache, error) @@ -228,7 +228,7 @@ func TestIdent(t *testing.T) { var cache *pkg.Cache if a, err := check.NewAbs(t.TempDir()); err != nil { t.Fatal(err) - } else if cache, err = pkg.Open(t.Context(), msg, 0, a); err != nil { + } else if cache, err = pkg.Open(t.Context(), msg, 0, 0, a); err != nil { t.Fatal(err) } t.Cleanup(cache.Close) @@ -252,6 +252,7 @@ func TestIdent(t *testing.T) { // on test completion. type cacheTestCase struct { name string + flags int early func(t *testing.T, base *check.Absolute) f func(t *testing.T, base *check.Absolute, c *pkg.Cache) want pkg.Checksum @@ -289,7 +290,7 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) { msg.SwapVerbose(testing.Verbose()) var scrubFunc func() error // scrub after hashing - if c, err := pkg.Open(t.Context(), msg, 1<<4, base); err != nil { + if c, err := pkg.Open(t.Context(), msg, tc.flags, 1<<4, base); err != nil { t.Fatalf("Open: error = %v", err) } else { t.Cleanup(c.Close) @@ -468,9 +469,7 @@ func TestCache(t *testing.T) { }() testCases := []cacheTestCase{ - {"file", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { - c.SetStrict(true) - + {"file", pkg.CValidateKnown, nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { identifier := (pkg.ID)(bytes.Repeat([]byte{ 0x75, 0xe6, 0x9d, 0x6d, 0xe7, 0x9f, }, 8)) @@ -593,7 +592,7 @@ func TestCache(t *testing.T) { if c0, err := unsafeOpen( t.Context(), message.New(nil), - 0, base, false, + 0, 0, base, false, ); err != nil { t.Fatalf("open: error = %v", err) } else { @@ -627,7 +626,7 @@ func TestCache(t *testing.T) { } }, pkg.MustDecode("St9rlE-mGZ5gXwiv_hzQ_B8bZP-UUvSNmf4nHUZzCMOumb6hKnheZSe0dmnuc4Q2")}, - {"directory", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { + {"directory", 0, nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { id := pkg.MustDecode( "HnySzeLQvSBZuTUcvfmLEX_OmH4yJWWH788NxuLuv7kVn8_uPM6Ks4rqFWM2NZJY", ) @@ -804,9 +803,7 @@ func TestCache(t *testing.T) { }) }, pkg.MustDecode("WVpvsVqVKg9Nsh744x57h51AuWUoUR2nnh8Md-EYBQpk6ziyTuUn6PLtF2e0Eu_d")}, - {"pending", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { - c.SetStrict(true) - + {"pending", pkg.CValidateKnown, nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { wantErr := stub.UniqueError(0xcafe) n, ready := make(chan struct{}), make(chan struct{}) go func() { @@ -876,7 +873,7 @@ func TestCache(t *testing.T) { <-wCureDone }, pkg.MustDecode("E4vEZKhCcL2gPZ2Tt59FS3lDng-d_2SKa2i5G_RbDfwGn6EemptFaGLPUDiOa94C")}, - {"scrub", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { + {"scrub", 0, nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { cureMany(t, c, []cureStep{ {"bad measured file", newStubFile( pkg.KindHTTPGet, @@ -1182,7 +1179,7 @@ func (a earlyFailureF) Cure(*pkg.FContext) error { func TestDependencyCureErrorEarly(t *testing.T) { checkWithCache(t, []cacheTestCase{ - {"early", nil, func(t *testing.T, _ *check.Absolute, c *pkg.Cache) { + {"early", 0, nil, func(t *testing.T, _ *check.Absolute, c *pkg.Cache) { _, _, err := c.Cure(earlyFailureF(8)) if !errors.Is(err, stub.UniqueError(0xcafe)) { t.Fatalf("Cure: error = %v", err) @@ -1205,7 +1202,7 @@ func TestNew(t *testing.T) { if _, err := pkg.Open( t.Context(), message.New(nil), - 0, check.MustAbs(container.Nonexistent), + 0, 0, check.MustAbs(container.Nonexistent), ); !reflect.DeepEqual(err, wantErr) { t.Errorf("Open: error = %#v, want %#v", err, wantErr) } @@ -1233,7 +1230,7 @@ func TestNew(t *testing.T) { if _, err := pkg.Open( t.Context(), message.New(nil), - 0, tempDir.Append("cache"), + 0, 0, tempDir.Append("cache"), ); !reflect.DeepEqual(err, wantErr) { t.Errorf("Open: error = %#v, want %#v", err, wantErr) } |
