MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestNewBackend

Method TestNewBackend

pkg/blobmanager/oci/backend_test.go:67–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65}
66
67func (s *testSuite) TestNewBackend() {
68 testCases := []struct {
69 name string
70 repo string
71 prefix string
72 opts []NewBackendOpt
73 wantErr bool
74 }{
75 {
76 name: "default prefix",
77 repo: "localhost:5000",
78 opts: []NewBackendOpt{},
79 },
80 {
81 name: "custom prefix",
82 repo: "localhost:5000",
83 prefix: "custom-prefix",
84 },
85 }
86
87 for _, tc := range testCases {
88 s.T().Run(tc.name, func(t *testing.T) {
89 var opts = make([]NewBackendOpt, 0)
90 if tc.prefix != "" {
91 opts = append(opts, WithPrefix(tc.prefix))
92 }
93
94 got, err := NewBackend(tc.repo, &RegistryOptions{}, opts...)
95 if tc.wantErr {
96 assert.Error(t, err)
97 } else {
98 assert.NoError(t, err)
99 assert.NotNil(t, got)
100 assert.Equal(t, tc.repo, got.repo)
101 if tc.prefix == "" {
102 assert.Equal(t, "chainloop", got.prefix)
103 } else {
104 assert.Equal(t, tc.prefix, got.prefix)
105 }
106 }
107 })
108 }
109}
110
111func (s *testSuite) TestExists() {
112 assert := assert.New(s.T())

Callers

nothing calls this directly

Calls 4

WithPrefixFunction · 0.85
NewBackendFunction · 0.70
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected