Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 26, 2024
1 parent 1c7dfe2 commit 8681ffa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion popx/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func RegisterMigrateSQLDownFlags(cmd *cobra.Command) *cobra.Command {

func MigrateSQLDown(cmd *cobra.Command, p MigrationProvider) (err error) {
steps := flagx.MustGetInt(cmd, "steps")
if steps < 1 {
if steps < 0 {
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "Flag --steps must be larger than 0.")
return cmdx.FailSilently(cmd)
}
Expand Down
11 changes: 11 additions & 0 deletions popx/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ func TestMigrateSQLUp(t *testing.T) {
run(t, newCmd(), nil, "status")
})

t.Run("migrate down but no steps", func(t *testing.T) {
stdout, stderr, err := cmdx.ExecCtx(ctx, newCmd(), nil, "down", "-y")
require.Error(t, err)

cupaloy.New(
cupaloy.CreateNewAutomatically(true),
cupaloy.FailOnUpdate(true),
cupaloy.SnapshotFileExtension(".txt"),
).SnapshotT(t, fmt.Sprintf("stdout: %s\nstderr: %s", stdout, stderr))
})

t.Run("migrate down but do not confirm", func(t *testing.T) {
run(t, newCmd(), bytes.NewBufferString("n\n"), "down", "--steps", "2")
})
Expand Down

0 comments on commit 8681ffa

Please sign in to comment.