Skip to content

Commit

Permalink
add integration tests for azure sql
Browse files Browse the repository at this point in the history
  • Loading branch information
KarnerTh committed Feb 8, 2023
1 parent d1be491 commit 2188ef6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions database/connector_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestNewConnector(t *testing.T) {
{connectionString: "postgresql://user:password@localhost:5432/yourDb", expectedDbType: Postgres},
{connectionString: "postgres://user:password@localhost:5432/yourDb", expectedDbType: Postgres},
{connectionString: "mysql://root:password@tcp(127.0.0.1:3306)/yourDb", expectedDbType: MySql},
{connectionString: "sqlserver://sa:securePassword1!@localhost:1433?database=mermerd_test", expectedDbType: MsSql},
}

for index, testCase := range testCases {
Expand Down
7 changes: 7 additions & 0 deletions database/database_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
testConnectionPostgres connectionParameter = connectionParameter{connectionString: "postgresql://user:password@localhost:5432/mermerd_test", schema: "public"}
testConnectionMySql connectionParameter = connectionParameter{connectionString: "mysql://root:password@tcp(127.0.0.1:3306)/mermerd_test", schema: "mermerd_test"}
testConnectionMsSql connectionParameter = connectionParameter{connectionString: "sqlserver://sa:securePassword1!@localhost:1433?database=mermerd_test", schema: "dbo"}
testConnectionAzure connectionParameter = connectionParameter{connectionString: "sqlserver://sa:securePassword1!@localhost:1434?database=mermerd_test", schema: "dbo"}
)

func TestDatabaseIntegrations(t *testing.T) {
Expand Down Expand Up @@ -51,6 +52,12 @@ func TestDatabaseIntegrations(t *testing.T) {
connectionString: testConnectionMsSql.connectionString,
schema: testConnectionMsSql.schema,
},
{
// Azure SQL is the same as MSSQL
dbType: MsSql,
connectionString: testConnectionAzure.connectionString,
schema: testConnectionAzure.schema,
},
}

for _, testCase := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion database/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPostgresEnums(t *testing.T) {
logrus.Error(err)
t.FailNow()
}
columns, err := connector.GetColumns(TableDetail{Schema: "public", Name: "test_2_enum"})
columns, err := connector.GetColumns(TableDetail{Schema: "public", Name: "test_2_enum"})

// Assert
for _, column := range columns {
Expand Down
15 changes: 15 additions & 0 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ services:
- ./mssql/entrypoint.sh:/usr/src/app/entrypoint.sh
working_dir: /usr/src/app
command: sh -c './entrypoint.sh & /opt/mssql/bin/sqlservr;'
mermerd-azure-db-test-db:
image: mcr.microsoft.com/azure-sql-edge:latest
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "securePassword1!"
ports:
- "1434:1433"
volumes:
- ./db-table-setup.sql:/usr/src/app/db-table-setup.sql
- ./mssql/mssql-setup.sql:/usr/src/app/mssql-setup.sql
- ./mssql/mssql-enum-setup.sql:/usr/src/app/mssql-enum-setup.sql
- ./mssql/mssql-multiple-databases.sql:/usr/src/app/mssql-multiple-databases.sql
- ./mssql/entrypoint.sh:/usr/src/app/entrypoint.sh
working_dir: /usr/src/app
command: sh -c './entrypoint.sh & /opt/mssql/bin/sqlservr;'
2 changes: 1 addition & 1 deletion test/mssql/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# Source: https://cardano.github.io/blog/2017/11/15/mssql-docker-container
wait_time=15s
wait_time=30s
password=securePassword1!

# wait for SQL Server to come up
Expand Down

0 comments on commit 2188ef6

Please sign in to comment.