Renamed new flags name '-tables', '-views', and '-enums'.

This commit is contained in:
SanjaiyKumar 2025-06-24 14:09:30 +05:30
parent dbfcec7fbe
commit 85fdfb01b3
4 changed files with 60 additions and 84 deletions

View file

@ -1,6 +1,7 @@
package sqlite
import (
"bytes"
"os"
"os/exec"
"reflect"
@ -432,8 +433,8 @@ func TestAllowTablesEnums(t *testing.T) {
cmd := exec.Command("jet",
"-source=SQLite",
"-dsn=file://"+testDatabaseFilePath,
"-allow-tables=actor,Address,CATEGORY , city ,film,rental,store",
"-allow-views=customer_list, film_list,STAFF_LIst",
"-tables=actor,Address,CATEGORY , city ,film,rental,store",
"-views=customer_list, film_list,STAFF_LIst",
"-path="+genDestDir)
cmd.Stderr = os.Stderr
@ -452,28 +453,22 @@ func TestAllowTablesEnums(t *testing.T) {
"film.go", "rental.go", "store.go", "customer_list.go", "film_list.go", "staff_list.go")
}
func TestAllowAndIgnoreTablesEnums(t *testing.T) {
func TestAllowAndIgnoreViews(t *testing.T) {
cmd := exec.Command("jet",
"-source=SQLite",
"-dsn=file://"+testDatabaseFilePath,
"-allow-tables=actor,Address,CATEGORY , city ,film,rental,store",
"-allow-views=customer_list, film_list,STAFF_LIst",
"-ignore-tables=actor,CATEGORY ,store",
"-views=customer_list, film_list,STAFF_LIst",
"-ignore-views=customer_list",
"-path="+genDestDir)
var stdOut bytes.Buffer
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Stdout = &stdOut
err := cmd.Run()
require.NoError(t, err)
require.Error(t, err)
require.Equal(t, "exit status 1", err.Error())
testutils.AssertFileNamesEqual(t, genDestDir+"/table", "actor.go", "address.go", "category.go", "city.go",
"film.go", "rental.go", "store.go", "table_use_schema.go")
testutils.AssertFileNamesEqual(t, genDestDir+"/view", "customer_list.go", "film_list.go", "staff_list.go",
"view_use_schema.go")
testutils.AssertFileNamesEqual(t, genDestDir+"/model", "actor.go", "address.go", "category.go", "city.go",
"film.go", "rental.go", "store.go", "customer_list.go", "film_list.go", "staff_list.go")
stdOutput := stdOut.String()
require.Contains(t, stdOutput, "ERROR: cannot use both -views and -ignore-views flags simultaneously. Please specify only one option.")
}