Added unit test cases for the new flags '-allow-tables', '-allow-views', and '-allow-enums'.
This commit is contained in:
parent
bfb02acb43
commit
c35892320d
4 changed files with 319 additions and 14 deletions
|
|
@ -1002,3 +1002,123 @@ func newAllTypesTableImpl(schemaName, tableName, alias string) allTypesTable {
|
|||
}
|
||||
}
|
||||
`
|
||||
|
||||
func TestAllowTablesViewsEnums(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
}{
|
||||
{
|
||||
name: "with dsn",
|
||||
args: []string{
|
||||
"-dsn=mysql://" + dbconfig.MySQLConnectionString(sourceIsMariaDB(), "dvds"),
|
||||
"-allow-tables=actor,ADDRESS,Category, city ,country,staff,store,rental",
|
||||
"-allow-views=actor_info,CUSTomER_LIST, film_list",
|
||||
"-allow-enums=film_list_rating,film_rating",
|
||||
"-path=" + genTestDir3,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "without dsn",
|
||||
args: []string{
|
||||
"-source=MySQL",
|
||||
"-dbname=dvds",
|
||||
"-host=" + dbconfig.MySqLHost,
|
||||
"-port=" + strconv.Itoa(dbconfig.MySQLPort),
|
||||
"-user=" + dbconfig.MySQLUser,
|
||||
"-password=" + dbconfig.MySQLPassword,
|
||||
"-allow-tables=actor,ADDRESS,Category, city ,country,staff,store,rental",
|
||||
"-allow-views=actor_info,CUSTomER_LIST, film_list",
|
||||
"-allow-enums=film_list_rating,film_rating",
|
||||
"-path=" + genTestDir3,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cmd := exec.Command("jet", tt.args...)
|
||||
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
err := cmd.Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/table", "category.go", "actor.go", "address.go",
|
||||
"city.go", "country.go", "staff.go", "store.go", "rental.go", "table_use_schema.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/view", "actor_info.go", "customer_list.go",
|
||||
"film_list.go", "view_use_schema.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/enum", "film_list_rating.go", "film_rating.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/model", "category.go", "actor.go", "address.go",
|
||||
"city.go", "country.go", "staff.go", "store.go", "rental.go", "actor_info.go",
|
||||
"customer_list.go", "film_list.go", "film_list_rating.go", "film_rating.go")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllowAndIgnoreTablesViewsEnums(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
}{
|
||||
{
|
||||
name: "with dsn",
|
||||
args: []string{
|
||||
"-dsn=mysql://" + dbconfig.MySQLConnectionString(sourceIsMariaDB(), "dvds"),
|
||||
"-allow-tables=actor,ADDRESS,Category, city ,country,staff,store,rental",
|
||||
"-allow-views=actor_info,CUSTomER_LIST, film_list",
|
||||
"-allow-enums=film_list_rating,film_rating",
|
||||
"-ignore-tables=actor,ADDRESS,store,rental",
|
||||
"-ignore-views=film_list",
|
||||
"-ignore-enums=film_rating",
|
||||
"-path=" + genTestDir3,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "without dsn",
|
||||
args: []string{
|
||||
"-source=MySQL",
|
||||
"-dbname=dvds",
|
||||
"-host=" + dbconfig.MySqLHost,
|
||||
"-port=" + strconv.Itoa(dbconfig.MySQLPort),
|
||||
"-user=" + dbconfig.MySQLUser,
|
||||
"-password=" + dbconfig.MySQLPassword,
|
||||
"-allow-tables=actor,ADDRESS,Category, city ,country,staff,store,rental",
|
||||
"-allow-views=actor_info,CUSTomER_LIST, film_list",
|
||||
"-allow-enums=film_list_rating,film_rating",
|
||||
"-ignore-tables=actor,ADDRESS,store,rental",
|
||||
"-ignore-views=film_list",
|
||||
"-ignore-enums=film_rating",
|
||||
"-path=" + genTestDir3,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cmd := exec.Command("jet", tt.args...)
|
||||
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
err := cmd.Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/table", "category.go", "actor.go", "address.go",
|
||||
"city.go", "country.go", "staff.go", "store.go", "rental.go", "table_use_schema.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/view", "actor_info.go", "customer_list.go",
|
||||
"film_list.go", "view_use_schema.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/enum", "film_list_rating.go", "film_rating.go")
|
||||
|
||||
testutils.AssertFileNamesEqual(t, genTestDir3+"/dvds/model", "category.go", "actor.go", "address.go",
|
||||
"city.go", "country.go", "staff.go", "store.go", "rental.go", "actor_info.go",
|
||||
"customer_list.go", "film_list.go", "film_list_rating.go", "film_rating.go")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue