Skip to content

Commit

Permalink
migrate/push: defult value to 'latest' flag (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
noamcattan authored Jun 19, 2024
1 parent a49559f commit 03ac207
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion atlasaction/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func MigratePush(ctx context.Context, client *atlasexec.Client, act Action) erro
}
switch latest := act.GetInput("latest"); latest {
case "false":
case "true":
case "true", "":
// Push the "latest" tag.
_, err = client.MigratePush(ctx, params)
if err != nil {
Expand Down
9 changes: 0 additions & 9 deletions atlasaction/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ func TestMigratePush(t *testing.T) {
tt.setInput("config", "file://testdata/config/broken.hcl")
tt.setInput("dir", "file://testdata/migrations")
tt.setInput("dir-name", "test-dir")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, `"testdata/config/broken.hcl" was not found`)
})
Expand All @@ -272,15 +271,13 @@ func TestMigratePush(t *testing.T) {
tt.setInput("config", "file://testdata/config/atlas.hcl")
tt.setInput("env", "broken-env")
tt.setInput("dir-name", "test-dir")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, `env "broken-env" not defined in config file`)
})
t.Run("broken dir", func(t *testing.T) {
tt := newT(t)
tt.setInput("dir", "file://some_broken_dir")
tt.setInput("dir-name", "test-dir")
tt.setInput("latest", "true")
tt.setInput("dev-url", "sqlite://file?mode=memory")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, `sql/migrate: stat some_broken_dir: no such file or directory`)
Expand Down Expand Up @@ -308,7 +305,6 @@ func TestMigratePushWithCloud(t *testing.T) {
tt.setInput("dir", "file://testdata/migrations")
tt.setInput("dir-name", "test-dir")
tt.setInput("dev-url", "broken-driver://")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, `unknown driver "broken-driver"`)
})
Expand All @@ -319,7 +315,6 @@ func TestMigratePushWithCloud(t *testing.T) {
tt.setInput("dir-name", "test-dir")
tt.setInput("dev-url", "sqlite://file?mode=memory")
tt.setInput("tag", "invalid-character@")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, `tag must be lowercase alphanumeric`)
})
Expand All @@ -335,7 +330,6 @@ func TestMigratePushWithCloud(t *testing.T) {
tt.setInput("dir-name", "test-dir")
tt.setInput("dev-url", "sqlite://file?mode=memory")
tt.setInput("tag", "valid-tag-123")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.NoError(t, err)
out, err := os.ReadFile("push-out.txt")
Expand Down Expand Up @@ -374,7 +368,6 @@ func TestMigratePushWithCloud(t *testing.T) {
tt.setInput("dir", "file://testdata/migrations")
tt.setInput("dev-url", "sqlite://file?mode=memory")
tt.setInput("dir-name", "test-dir")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.NoError(t, err)
})
Expand All @@ -384,7 +377,6 @@ func TestMigratePushWithCloud(t *testing.T) {
tt.setInput("dir", "file://testdata/migrations")
tt.setInput("dir-name", "test-#dir")
tt.setInput("dev-url", "sqlite://file?mode=memory")
tt.setInput("latest", "true")
err := MigratePush(context.Background(), tt.cli, tt.act)
require.ErrorContains(t, err, "slug must be lowercase alphanumeric")
})
Expand Down Expand Up @@ -438,7 +430,6 @@ func TestMigrateE2E(t *testing.T) {
tt.setInput("dir", "file://testdata/migrations")
tt.setInput("dir-name", "test-dir")
tt.setInput("dev-url", "sqlite://file?mode=memory")
tt.setInput("latest", "true")
tt.env["GITHUB_REPOSITORY"] = "repository"
tt.env["GITHUB_HEAD_REF"] = "testing-branch"
tt.env["GITHUB_REF_NAME"] = "refs/pulls/6/merge"
Expand Down
1 change: 0 additions & 1 deletion migrate/push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ inputs:
description: |
If true, push also to the "latest" tag.
required: false
default: true
config:
description: |
The path to the Atlas configuration file. By default, Atlas will look for a file
Expand Down

0 comments on commit 03ac207

Please sign in to comment.