(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func TestCreateStorageBackend(t *testing.T) { |
| 108 | tests := []struct { |
| 109 | name string |
| 110 | config *StorageConfig |
| 111 | expectError bool |
| 112 | expectType string |
| 113 | }{ |
| 114 | { |
| 115 | name: "rekor backend", |
| 116 | config: &StorageConfig{ |
| 117 | Backend: "rekor", |
| 118 | BaseURL: "https://rekor.sigstore.dev", |
| 119 | }, |
| 120 | expectError: false, |
| 121 | expectType: "*vsa.RekorBackend", |
| 122 | }, |
| 123 | { |
| 124 | name: "local backend", |
| 125 | config: &StorageConfig{ |
| 126 | Backend: "local", |
| 127 | BaseURL: "/tmp/vsa", |
| 128 | }, |
| 129 | expectError: false, |
| 130 | expectType: "*vsa.LocalBackend", |
| 131 | }, |
| 132 | { |
| 133 | name: "unsupported backend", |
| 134 | config: &StorageConfig{ |
| 135 | Backend: "s3", |
| 136 | BaseURL: "s3://bucket/path", |
| 137 | }, |
| 138 | expectError: true, |
| 139 | expectType: "", |
| 140 | }, |
| 141 | } |
| 142 | |
| 143 | for _, tt := range tests { |
| 144 | t.Run(tt.name, func(t *testing.T) { |
| 145 | backend, err := CreateStorageBackend(tt.config) |
| 146 | |
| 147 | if tt.expectError { |
| 148 | assert.Error(t, err) |
| 149 | assert.Nil(t, backend) |
| 150 | } else { |
| 151 | assert.NoError(t, err) |
| 152 | assert.NotNil(t, backend) |
| 153 | // Note: We can't easily test the exact type without reflection, |
| 154 | // but we can test that the backend implements the interface |
| 155 | assert.Implements(t, (*StorageBackend)(nil), backend) |
| 156 | } |
| 157 | }) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | func TestUploadVSAEnvelope_EmptyConfigs(t *testing.T) { |
| 162 | // Create a temporary file for the envelope |
nothing calls this directly
no test coverage detected