Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Sep 25, 2024
1 parent 7570c11 commit 9bf786c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
5 changes: 3 additions & 2 deletions internal/db/push/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ func TestPushAll(t *testing.T) {

t.Run("throws error on seed failure", func(t *testing.T) {
// Setup in-memory fs
fsys := &fstest.OpenErrorFs{DenyPath: filepath.Join(utils.SupabaseDirPath, "seed.sql")}
_, _ = fsys.Create(filepath.Join(utils.SupabaseDirPath, "seed.sql"))
seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql")
fsys := &fstest.OpenErrorFs{DenyPath: seedPath}
_, _ = fsys.Create(seedPath)
path := filepath.Join(utils.MigrationsDir, "0_test.sql")
require.NoError(t, afero.WriteFile(fsys, path, []byte{}, 0644))
// Setup mock postgres
Expand Down
2 changes: 1 addition & 1 deletion internal/db/reset/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func TestResetRemote(t *testing.T) {
fsys := afero.NewMemMapFs()
path := filepath.Join(utils.MigrationsDir, "0_schema.sql")
require.NoError(t, afero.WriteFile(fsys, path, nil, 0644))
seedPath := filepath.Join(filepath.Join(utils.SupabaseDirPath, "seed.sql"))
seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql")
// Will raise an error when seeding
require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644))
// Setup mock postgres
Expand Down
13 changes: 5 additions & 8 deletions internal/migration/apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,12 @@ func TestSeedDatabase(t *testing.T) {
})

t.Run("throws error on read failure", func(t *testing.T) {
// Wrap the fs with OpenErrorFs
errorFs := &fstest.OpenErrorFs{
DenyPath: filepath.Join(utils.SupabaseDirPath, "seed.sql"),
}
_, _ = errorFs.Create(filepath.Join(utils.SupabaseDirPath, "seed.sql"))

// Setup in-memory fs
seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql")
fsys := &fstest.OpenErrorFs{DenyPath: seedPath}
_, _ = fsys.Create(seedPath)
// Run test
err := SeedDatabase(context.Background(), nil, errorFs)

err := SeedDatabase(context.Background(), nil, fsys)
// Check error
assert.ErrorIs(t, err, os.ErrPermission)
})
Expand Down
8 changes: 4 additions & 4 deletions pkg/config/templates/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ default_pool_size = 20
max_client_conn = 100

[db.seed]
# Determines whether to seed the database after migrations during a db reset
# If enabled, seeds the database after migrations during a db reset.
enabled = true
# Specifies seed files to load during db reset using glob patterns
# Base path is the Supabase project folder
# Example: sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql']
# Specifies an ordered list of seed files to load during db reset.
# Supports glob patterns relative to supabase directory. For example:
# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql']
sql_paths = ['./seed.sql']

[realtime]
Expand Down
10 changes: 5 additions & 5 deletions pkg/config/testdata/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ default_pool_size = 20
max_client_conn = 100

[db.seed]
# Determines whether to seed the database after migrations during a db reset
# If enabled, seeds the database after migrations during a db reset.
enabled = true
# Specifies seed files to load during db reset using glob patterns
# Base path is the Supabase project folder
# Example: path = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql']
path = ['./seed.sql']
# Specifies an ordered list of seed files to load during db reset.
# Supports glob patterns relative to supabase directory. For example:
# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql']
sql_paths = ['./seed.sql']

[realtime]
enabled = true
Expand Down

0 comments on commit 9bf786c

Please sign in to comment.