MCPcopy Create free account
hub / github.com/conforma/cli / TestCreateStorageBackend

Function TestCreateStorageBackend

internal/validate/vsa/storage_test.go:107–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func 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
161func TestUploadVSAEnvelope_EmptyConfigs(t *testing.T) {
162 // Create a temporary file for the envelope

Callers

nothing calls this directly

Calls 3

CreateStorageBackendFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected