Skip to content

Commit 05ee3e0

Browse files
committed
fix: trim space for migration version
1 parent 55f6a8e commit 05ee3e0

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

internal/seed/buckets/buckets_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public = false`
3030
bucketPath := filepath.Join(utils.SupabaseDirPath, "images")
3131
require.NoError(t, fsys.Mkdir(bucketPath, 0755))
3232
// Setup mock api
33+
defer gock.OffAll()
3334
gock.New(utils.Config.Api.ExternalUrl).
3435
Get("/storage/v1/bucket").
3536
Reply(http.StatusOK).
@@ -54,6 +55,7 @@ public = false`
5455

5556
t.Run("ignores unconfigured buckets", func(t *testing.T) {
5657
// Setup mock api
58+
defer gock.OffAll()
5759
gock.New(utils.Config.Api.ExternalUrl).
5860
Get("/storage/v1/bucket").
5961
Reply(http.StatusOK).

internal/utils/tenant/database_test.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,55 @@ import (
1313
)
1414

1515
func TestGetDatabaseVersion(t *testing.T) {
16-
t.Run("retrieves database version successfully", func(t *testing.T) {
17-
token := apitest.RandomAccessToken(t)
18-
t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
16+
// Setup valid access token
17+
token := apitest.RandomAccessToken(t)
18+
t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
19+
// Setup valid project ref
20+
projectRef := apitest.RandomProjectRef()
1921

22+
t.Run("retrieves database version successfully", func(t *testing.T) {
23+
// Setup mock api
2024
defer gock.OffAll()
21-
projectRef := apitest.RandomProjectRef()
22-
mockPostgres := api.V1ProjectWithDatabaseResponse{Id: projectRef}
25+
mockPostgres := api.V1ProjectWithDatabaseResponse{}
2326
mockPostgres.Database.Version = "14.1.0.99"
2427
gock.New(utils.DefaultApiHost).
2528
Get("/v1/projects/" + projectRef).
2629
Reply(http.StatusOK).
2730
JSON(mockPostgres)
28-
31+
// Run test
2932
version, err := GetDatabaseVersion(context.Background(), projectRef)
30-
33+
// Check error
3134
assert.NoError(t, err)
3235
assert.Equal(t, "14.1.0.99", version)
3336
assert.Empty(t, apitest.ListUnmatchedRequests())
3437
})
3538

3639
t.Run("handles project not found", func(t *testing.T) {
37-
token := apitest.RandomAccessToken(t)
38-
t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
39-
40+
// Setup mock api
4041
defer gock.OffAll()
4142
projectRef := apitest.RandomProjectRef()
4243
gock.New(utils.DefaultApiHost).
4344
Get("/v1/projects/" + projectRef).
4445
Reply(http.StatusNotFound)
45-
46+
// Run test
4647
version, err := GetDatabaseVersion(context.Background(), projectRef)
47-
48+
// Check error
4849
assert.ErrorContains(t, err, "unexpected retrieve project status 404:")
4950
assert.Empty(t, version)
5051
assert.Empty(t, apitest.ListUnmatchedRequests())
5152
})
5253

5354
t.Run("handles empty database version", func(t *testing.T) {
54-
token := apitest.RandomAccessToken(t)
55-
t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
56-
55+
// Setup mock api
5756
defer gock.OffAll()
5857
projectRef := apitest.RandomProjectRef()
5958
gock.New(utils.DefaultApiHost).
6059
Get("/v1/projects/" + projectRef).
6160
Reply(http.StatusOK).
62-
JSON(api.V1ProjectWithDatabaseResponse{Id: projectRef})
63-
61+
JSON(api.V1ProjectWithDatabaseResponse{})
62+
// Run test
6463
version, err := GetDatabaseVersion(context.Background(), projectRef)
65-
64+
// Check error
6665
assert.ErrorIs(t, err, errDatabaseVersion)
6766
assert.Empty(t, version)
6867
assert.Empty(t, apitest.ListUnmatchedRequests())

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ func (c *config) Load(path string, fsys fs.FS, overrides ...ConfigEditor) error
634634
}
635635
}
636636
if version, err := fs.ReadFile(fsys, builder.StorageMigrationPath); err == nil && len(version) > 0 {
637-
c.Storage.TargetMigration = string(version)
637+
c.Storage.TargetMigration = strings.TrimSpace(string(version))
638638
}
639639
if version, err := fs.ReadFile(fsys, builder.EdgeRuntimeVersionPath); err == nil && len(version) > 0 {
640640
c.EdgeRuntime.Image = replaceImageTag(Images.EdgeRuntime, string(version))

0 commit comments

Comments
 (0)