MCPcopy Index your code
hub / github.com/regclient/regclient / TestImageCheckBase

Function TestImageCheckBase

cmd/regctl/image_test.go:22–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestImageCheckBase(t *testing.T) {
23 t.Parallel()
24 ctx := context.Background()
25 regHandler := olareg.New(oConfig.Config{
26 Storage: oConfig.ConfigStorage{
27 StoreType: oConfig.StoreMem,
28 RootDir: "../../testdata",
29 },
30 })
31 ts := httptest.NewServer(regHandler)
32 tsURL, _ := url.Parse(ts.URL)
33 tsHost := tsURL.Host
34 t.Cleanup(func() {
35 ts.Close()
36 _ = regHandler.Close()
37 })
38 rcOpts := []regclient.Opt{
39 regclient.WithConfigHost(
40 config.Host{
41 Name: tsHost,
42 TLS: config.TLSDisabled,
43 },
44 config.Host{
45 Name: "registry.example.org",
46 Hostname: tsHost,
47 TLS: config.TLSDisabled,
48 },
49 ),
50 }
51
52 rb, err := ref.New("ocidir://../../testdata/testrepo:b3")
53 if err != nil {
54 t.Fatalf("failed to parse ref: %v", err)
55 }
56 rc := regclient.New(rcOpts...)
57 mb, err := rc.ManifestHead(ctx, rb, regclient.WithManifestRequireDigest())
58 if err != nil {
59 t.Fatalf("failed to head ref %s: %v", rb.CommonName(), err)
60 }
61 dig := mb.GetDescriptor().Digest
62
63 tt := []struct {
64 name string
65 args []string
66 expectErr error
67 expectOut string
68 }{
69 {
70 name: "missing annotation",
71 args: []string{"image", "check-base", tsHost + "/testrepo:v1"},
72 expectErr: errs.ErrMissingAnnotation,
73 },
74 {
75 name: "annotation v2",
76 args: []string{"image", "check-base", tsHost + "/testrepo:v2"},
77 expectErr: errs.ErrMismatch,
78 expectOut: "base image has changed",
79 },

Callers

nothing calls this directly

Calls 11

WithConfigHostFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
cobraTestFunction · 0.85
ParseMethod · 0.80
CommonNameMethod · 0.80
CloseMethod · 0.65
ManifestHeadMethod · 0.65
GetDescriptorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…