Skip to content

Commit

Permalink
test: Fix dialect tests; remove non-dynamic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 7, 2023
1 parent 71db079 commit 41839c1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 482 deletions.
138 changes: 2 additions & 136 deletions internal/database/dialect/mariadb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,6 @@ import (
v1 "k8s.io/api/core/v1"
)

func TestMariaDB_AnalyzeQuery(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.AnalyzeQuery()
assert.Equal(t, tt.want, got)
})
}
}

func TestMariaDB_DatabaseEnvNames(t *testing.T) {
tests := []struct {
name string
want []string
}{
{"default", []string{"MARIADB_DATABASE"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.DatabaseEnvNames()
assert.Equal(t, got, tt.want)
})
}
}

func TestMariaDB_DefaultPort(t *testing.T) {
tests := []struct {
name string
want uint16
}{
{"default", 3306},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.DefaultPort()
assert.Equal(t, tt.want, got)
})
}
}

func TestMariaDB_DefaultUser(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "root"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.DefaultUser()
assert.Equal(t, tt.want, got)
})
}
}

func TestMariaDB_DropDatabaseQuery(t *testing.T) {
type args struct {
database string
Expand Down Expand Up @@ -213,38 +149,6 @@ func TestMariaDB_ListDatabasesQuery(t *testing.T) {
}
}

func TestMariaDB_ListTablesQuery(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "show tables"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.ListTablesQuery()
assert.Equal(t, tt.want, got)
})
}
}

func TestMariaDB_Name(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "mariadb"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.Name()
assert.Equal(t, tt.want, got)
})
}
}

func TestMariaDB_PasswordEnvNames(t *testing.T) {
type args struct {
c config.Global
Expand All @@ -254,8 +158,8 @@ func TestMariaDB_PasswordEnvNames(t *testing.T) {
args args
want []string
}{
{"default", args{}, []string{"MARIADB_PASSWORD"}},
{"root", args{config.Global{Username: "root"}}, []string{"MARIADB_ROOT_PASSWORD"}},
{"default", args{}, []string{"MARIADB_PASSWORD", "MYSQL_PASSWORD"}},
{"root", args{config.Global{Username: "root"}}, []string{"MARIADB_ROOT_PASSWORD", "MYSQL_ROOT_PASSWORD"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -266,28 +170,6 @@ func TestMariaDB_PasswordEnvNames(t *testing.T) {
}
}

func TestMariaDB_PodLabels(t *testing.T) {
tests := []struct {
name string
want []kubernetes.LabelQueryable
}{
{"default", []kubernetes.LabelQueryable{
kubernetes.LabelQueryAnd{
{Name: "app.kubernetes.io/name", Value: "mariadb"},
{Name: "app.kubernetes.io/component", Value: "primary"},
},
kubernetes.LabelQuery{Name: "app", Value: "mariadb"},
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.PodLabels()
assert.Equal(t, got, tt.want)
})
}
}

func TestMariaDB_RestoreCommand(t *testing.T) {
type args struct {
conf config.Restore
Expand Down Expand Up @@ -323,22 +205,6 @@ func TestMariaDB_RestoreCommand(t *testing.T) {
}
}

func TestMariaDB_UserEnvNames(t *testing.T) {
tests := []struct {
name string
want []string
}{
{"default", []string{"MARIADB_USER"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MariaDB{}
got := ma.UserEnvNames()
assert.Equal(t, got, tt.want)
})
}
}

func TestMariaDB_DumpExtension(t *testing.T) {
type args struct {
format sqlformat.Format
Expand Down
172 changes: 1 addition & 171 deletions internal/database/dialect/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,90 +12,6 @@ import (
v1 "k8s.io/api/core/v1"
)

func TestMongoDB_AnalyzeQuery(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.AnalyzeQuery()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_DatabaseEnvNames(t *testing.T) {
tests := []struct {
name string
want []string
}{
{"default", []string{"MONGODB_EXTRA_DATABASES"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.DatabaseEnvNames()
assert.Equal(t, got, tt.want)
})
}
}

func TestMongoDB_DefaultPort(t *testing.T) {
tests := []struct {
name string
want uint16
}{
{"default", 27017},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.DefaultPort()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_DefaultUser(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "root"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.DefaultUser()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_DropDatabaseQuery(t *testing.T) {
type args struct {
database string
}
tests := []struct {
name string
args args
want string
}{
{"database", args{"database"}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.DropDatabaseQuery(tt.args.database)
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_DumpCommand(t *testing.T) {
type args struct {
conf config.Dump
Expand Down Expand Up @@ -202,54 +118,6 @@ func TestMongoDB_FilterPods(t *testing.T) {
}
}

func TestMongoDB_ListDatabasesQuery(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "db.getMongo().getDBNames().forEach(function(db){ print(db) })"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.ListDatabasesQuery()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_ListTablesQuery(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "show collections"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.ListTablesQuery()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_Name(t *testing.T) {
tests := []struct {
name string
want string
}{
{"default", "mongodb"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.Name()
assert.Equal(t, tt.want, got)
})
}
}

func TestMongoDB_PasswordEnvNames(t *testing.T) {
type args struct {
c config.Global
Expand All @@ -260,7 +128,7 @@ func TestMongoDB_PasswordEnvNames(t *testing.T) {
want []string
}{
{"default", args{}, []string{"MONGODB_EXTRA_PASSWORDS"}},
{"root", args{config.Global{Host: "1.1.1.1", Username: "root"}}, []string{"MONGODB_ROOT_PASSWORD"}},
{"root", args{config.Global{Username: "root"}}, []string{"MONGODB_ROOT_PASSWORD"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -271,28 +139,6 @@ func TestMongoDB_PasswordEnvNames(t *testing.T) {
}
}

func TestMongoDB_PodLabels(t *testing.T) {
tests := []struct {
name string
want []kubernetes.LabelQueryable
}{
{"default", []kubernetes.LabelQueryable{
kubernetes.LabelQueryAnd{
{Name: "app.kubernetes.io/name", Value: "mongodb"},
{Name: "app.kubernetes.io/component", Value: "mongodb"},
},
kubernetes.LabelQuery{Name: "app", Value: "mongodb"},
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.PodLabels()
assert.Equal(t, got, tt.want)
})
}
}

func TestMongoDB_RestoreCommand(t *testing.T) {
type args struct {
conf config.Restore
Expand Down Expand Up @@ -338,22 +184,6 @@ func TestMongoDB_RestoreCommand(t *testing.T) {
}
}

func TestMongoDB_UserEnvNames(t *testing.T) {
tests := []struct {
name string
want []string
}{
{"default", []string{"MONGODB_EXTRA_USERNAMES", "MONGODB_ROOT_USER"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ma := MongoDB{}
got := ma.UserEnvNames()
assert.Equal(t, got, tt.want)
})
}
}

func TestMongoDB_DumpExtension(t *testing.T) {
type args struct {
format sqlformat.Format
Expand Down
Loading

0 comments on commit 41839c1

Please sign in to comment.