()
| 65 | } |
| 66 | |
| 67 | func (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 | |
| 111 | func (s *testSuite) TestExists() { |
| 112 | assert := assert.New(s.T()) |
nothing calls this directly
no test coverage detected