Skip to content

Commit

Permalink
test(client): add the schema field to the client's tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed Oct 14, 2022
1 parent 514766b commit d2e2b8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ services:
- DB_NAME=users
- DB_PORT=5432
- DB_DRIVER=postgres
- DB_SCHEMA=public
entrypoint: ["/bin/bash", "./scripts/entrypoint.dev.sh"]
networks:
- dblab
Expand Down
15 changes: 14 additions & 1 deletion pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
host string
port string
name string
schema string
)

func TestMain(m *testing.M) {
Expand All @@ -32,14 +33,15 @@ func TestMain(m *testing.M) {
host = os.Getenv("DB_HOST")
port = os.Getenv("DB_PORT")
name = os.Getenv("DB_NAME")
schema = os.Getenv("DB_SCHEMA")

os.Exit(m.Run())
}

func generateURL(driver string) string {
switch driver {
case "postgres":
return fmt.Sprintf("%s://%s:%s@%s:%s/%s?sslmode=mode", driver, user, password, host, port, name)
return fmt.Sprintf("%s://%s:%s@%s:%s/%s?sslmode=disable", driver, user, password, host, port, name)
case "mysql":
return fmt.Sprintf("%s://%s:%s@tcp(%s:%s)/%s", driver, user, password, host, port, name)
case "sqlite3":
Expand Down Expand Up @@ -84,6 +86,7 @@ func TestNewClientByUserData(t *testing.T) {
DBName: name,
SSL: "disable",
Limit: 50,
Schema: schema,
}

c, err := New(opts)
Expand All @@ -106,6 +109,7 @@ func TestNewClientPing(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 50,
}
Expand Down Expand Up @@ -134,6 +138,7 @@ func TestQuery(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -159,6 +164,7 @@ func TestTableContent(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -184,6 +190,7 @@ func TestShowTables(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -208,6 +215,7 @@ func TestTableStructure(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -234,6 +242,7 @@ func TestConstraints(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand Down Expand Up @@ -262,6 +271,7 @@ func TestIndexes(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -287,6 +297,7 @@ func TestCountTable(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand All @@ -311,6 +322,7 @@ func TestMetadata(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand Down Expand Up @@ -353,6 +365,7 @@ func TestTotalPages(t *testing.T) {
Host: host,
Port: port,
DBName: name,
Schema: schema,
SSL: "disable",
Limit: 100,
}
Expand Down

0 comments on commit d2e2b8e

Please sign in to comment.