From 42219b235093a1bb2bd18bd16ad2e4a77e912125 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Wed, 13 Mar 2019 09:40:09 +0530 Subject: [PATCH] Added unit test case --- physical/mssql/mssql_test.go | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/physical/mssql/mssql_test.go b/physical/mssql/mssql_test.go index 9c55228018fe..b2cdf27e3a18 100644 --- a/physical/mssql/mssql_test.go +++ b/physical/mssql/mssql_test.go @@ -56,3 +56,50 @@ func TestMSSQLBackend(t *testing.T) { physical.ExerciseBackend(t, b) physical.ExerciseBackend_ListPrefix(t, b) } + +func TestMSSQLBackend_schema(t *testing.T) { + server := os.Getenv("MSSQL_SERVER") + if server == "" { + t.SkipNow() + } + + database := os.Getenv("MSSQL_DB") + if database == "" { + database = "test" + } + + table := os.Getenv("MSSQL_TABLE") + if table == "" { + table = "test" + } + + username := os.Getenv("MSSQL_USERNAME") + password := os.Getenv("MSSQL_PASSWORD") + + // Run vault tests + logger := logging.NewVaultLogger(log.Debug) + + b, err := NewMSSQLBackend(map[string]string{ + "server": server, + "database": database, + "schema": test, + "table": table, + "username": username, + "password": password, + }, logger) + + if err != nil { + t.Fatalf("Failed to create new backend: %v", err) + } + + defer func() { + mssql := b.(*MSSQLBackend) + _, err := mssql.client.Exec("DROP TABLE " + mssql.dbTable) + if err != nil { + t.Fatalf("Failed to drop table: %v", err) + } + }() + + physical.ExerciseBackend(t, b) + physical.ExerciseBackend_ListPrefix(t, b) +}