Skip to content

Commit

Permalink
internal/atlascloud: support maria (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemtam authored Mar 16, 2023
1 parent fd4e7d0 commit 0ce6699
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ariga.io/atlas v0.9.1-0.20230130073334-c0b12de7df90 h1:MIcT+crELxJjhETKTAxGvLhcwclJWFW0wBpFNqQRSmA=
ariga.io/atlas v0.9.1-0.20230130073334-c0b12de7df90/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
ariga.io/atlas v0.9.2-0.20230309154950-f1b6be5375db h1:SavN+Y+hFUqBwtuUCMIWnCdtiaczH0aXgYidA4joivo=
ariga.io/atlas v0.9.2-0.20230309154950-f1b6be5375db/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
github.com/99designs/gqlgen v0.17.2/go.mod h1:K5fzLKwtph+FFgh9j7nFbRUdBKvTcGnsta51fsMTn3o=
Expand Down
1 change: 1 addition & 0 deletions internal/atlascloud/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enum Driver {
MYSQL
POSTGRESQL
SQLITE
MARIADB
}

enum ArchiveFormat {
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func driver(s string) (atlascloud.Driver, error) {
return atlascloud.DriverMysql, nil
case "sqlite":
return atlascloud.DriverSqlite, nil
case "maria", "mariadb":
return atlascloud.DriverMariadb, nil
default:
return "", fmt.Errorf("unknown driver %q", s)
}
Expand Down
56 changes: 34 additions & 22 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,39 @@ func TestArchive(t *testing.T) {
}

func TestInput(t *testing.T) {
env := map[string]string{
"GITHUB_REPOSITORY": "ariga/test",
"GITHUB_SHA": "1234567890",
"INPUT_DIR": "migrations/",
"INPUT_DRIVER": "mysql",
"GITHUB_REF_NAME": "master",
"GITHUB_EVENT_PATH": "internal/testdata/push_event.json",
for _, tc := range []struct {
db string
driver atlascloud.Driver
}{
{"mysql", atlascloud.DriverMysql},
{"maria", atlascloud.DriverMariadb},
{"postgres", atlascloud.DriverPostgresql},
{"sqlite", atlascloud.DriverSqlite},
} {
t.Run(tc.db, func(t *testing.T) {
env := map[string]string{
"GITHUB_REPOSITORY": "ariga/test",
"GITHUB_SHA": "1234567890",
"INPUT_DIR": "migrations/",
"INPUT_DRIVER": tc.db,
"GITHUB_REF_NAME": "master",
"GITHUB_EVENT_PATH": "internal/testdata/push_event.json",
}
act := githubactions.New(githubactions.WithGetenv(func(key string) string {
return env[key]
}))
input, err := Input(act)
require.NoError(t, err)
require.EqualValues(t, atlascloud.ReportDirInput{
Repo: "ariga/test",
Commit: "1234567890",
Branch: "master",
Path: "migrations/",
Driver: tc.driver,
Url: "https://github.com/ariga/atlas-sync-action/commit/4a3f0bcb6dff19078393728f1b69d89d853771eb",
DirFormat: atlascloud.DirFormatAtlas,
ArchiveFormat: atlascloud.ArchiveFormatB64Tar,
}, input)
})
}
act := githubactions.New(githubactions.WithGetenv(func(key string) string {
return env[key]
}))
input, err := Input(act)
require.NoError(t, err)
require.EqualValues(t, atlascloud.ReportDirInput{
Repo: "ariga/test",
Commit: "1234567890",
Branch: "master",
Path: "migrations/",
Driver: atlascloud.DriverMysql,
Url: "https://github.com/ariga/atlas-sync-action/commit/4a3f0bcb6dff19078393728f1b69d89d853771eb",
DirFormat: atlascloud.DirFormatAtlas,
ArchiveFormat: atlascloud.ArchiveFormatB64Tar,
}, input)
}

0 comments on commit 0ce6699

Please sign in to comment.