Skip to content

Commit b89a945

Browse files
authored
fix: skip bucket seeding (#5158)
* fix * test
1 parent 0dc6a47 commit b89a945

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

internal/seed/buckets/buckets.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import (
1111
)
1212

1313
func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs) error {
14+
if len(projectRef) == 0 && len(utils.Config.Storage.Buckets) == 0 {
15+
return nil
16+
}
1417
api, err := client.NewStorageAPI(ctx, projectRef)
1518
if err != nil {
1619
return err

internal/seed/buckets/buckets_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,24 @@ public = false`
5454
})
5555

5656
t.Run("ignores unconfigured buckets", func(t *testing.T) {
57-
// Setup mock api
58-
defer gock.OffAll()
57+
t.Cleanup(func() {
58+
utils.Config.Storage.TargetMigration = ""
59+
gock.OffAll()
60+
})
61+
utils.Config.Storage.TargetMigration = "custom-metadata"
5962
gock.New(utils.Config.Api.ExternalUrl).
6063
Get("/storage/v1/bucket").
61-
Reply(http.StatusOK).
62-
JSON([]storage.BucketResponse{})
64+
Reply(http.StatusBadRequest).
65+
JSON(map[string]string{
66+
"statusCode": "403",
67+
"error": "Unauthorized",
68+
"message": "new row violates row-level security policy",
69+
})
6370
// Run test
6471
err := Run(context.Background(), "", false, afero.NewMemMapFs())
6572
// Check error
6673
assert.NoError(t, err)
74+
assert.Len(t, gock.Pending(), 1)
6775
assert.Empty(t, apitest.ListUnmatchedRequests())
6876
})
6977
}

0 commit comments

Comments
 (0)