this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: use ocimem in its immutable form in all tests

Unfortunately, ocimem.New defaults to a mutable in-memory registry,
which hides any unintended mutations in our tests
as we should be trying to mimic a realistic immutable registry setup.

The only exception is a modregistry client test
which does expect to be able to delete a tag, but that one is fine.

Raised https://github.com/cue-labs/oci/issues/33 to track making
ocimem.New default to an immutable registry, and opting into mutability.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I0368f075455640e360601b047cfb62b86e3b064c
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195730
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+6 -5
+1 -1
cmd/cue/cmd/script_test.go
··· 188 188 usage() 189 189 } 190 190 191 - srv, err := registrytest.NewServer(ocimem.New(), auth) 191 + srv, err := registrytest.NewServer(ocimem.NewWithConfig(&ocimem.Config{ImmutableTags: true}), auth) 192 192 if err != nil { 193 193 ts.Fatalf("cannot start registrytest server: %v", err) 194 194 }
+1 -1
internal/registrytest/registry.go
··· 108 108 // 109 109 // The Registry should be closed after use. 110 110 func New(fsys fs.FS, prefix string) (*Registry, error) { 111 - r := ocimem.New() 111 + r := ocimem.NewWithConfig(&ocimem.Config{ImmutableTags: true}) 112 112 113 113 authConfigData, err := upload(context.Background(), ocifilter.Sub(r, prefix), fsys) 114 114 if err != nil {
+1 -1
mod/modconfig/modconfig_test.go
··· 144 144 package x 145 145 `)) 146 146 ctx := context.Background() 147 - rmem := ocimem.New() 147 + rmem := ocimem.NewWithConfig(&ocimem.Config{ImmutableTags: true}) 148 148 err := registrytest.Upload(ctx, rmem, txtarfs.FS(modules)) 149 149 qt.Assert(t, qt.IsNil(err)) 150 150 rh := ociserver.New(rmem, nil)
+3 -2
mod/modregistry/client_test.go
··· 40 40 ) 41 41 42 42 func newTestClient(t *testing.T) *Client { 43 - return NewClient(ocimem.New()) 43 + return NewClient(ocimem.NewWithConfig(&ocimem.Config{ImmutableTags: true})) 44 44 } 45 45 46 46 func TestPutGetModule(t *testing.T) { ··· 238 238 ` 239 239 ctx := context.Background() 240 240 mv := module.MustParseVersion("foo.com/bar@v0.5.100") 241 - reg := ocimem.New() 241 + // Note that we delete a tag below, so we want a mutable registry. 242 + reg := ocimem.NewWithConfig(&ocimem.Config{ImmutableTags: false}) 242 243 243 244 c := NewClient(reg) 244 245 zipData := putModule(t, c, mv, testMod)