From 50f850f901fd45b20ba60f902fd985537b0de304 Mon Sep 17 00:00:00 2001 From: Kareem Mahlees Date: Fri, 16 Feb 2024 21:00:40 +0200 Subject: [PATCH] =?UTF-8?q?test:=20should=20hit=2090%=20now=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/database_test.go | 16 +++++++++++++++- internal/db/tables_test.go | 3 +++ internal/server_test.go | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/internal/db/database_test.go b/internal/db/database_test.go index 5e1ccdd..ea381d1 100644 --- a/internal/db/database_test.go +++ b/internal/db/database_test.go @@ -103,6 +103,15 @@ func (suite *DatabaseTestSuite) TestListDatabases() { assert.Nil(t, err) assert.Greater(t, len(dbs), 0) + + switch provider { + // we reverse the order here to intentionally make the query fail + case lib.SQLITE3: + _, err = db.ListDatabasesPgMySQL(suite.sqliteConnection, provider) + case lib.PSQL, lib.MYSQL: + _, err = db.ListDatabasesSqlite(con) + } + assert.NotNil(t, err) } } @@ -117,9 +126,14 @@ func (suite *DatabaseTestSuite) TestCreateDatabase() { switch provider { case lib.PSQL, lib.MYSQL: err = db.CreatePgMysqlDatabase(con, provider, "metax") + assert.Nil(t, err) } - assert.Nil(t, err) + switch provider { + case lib.PSQL, lib.MYSQL: + err = db.CreatePgMysqlDatabase(con, provider, "true") + assert.NotNil(t, err) + } } } diff --git a/internal/db/tables_test.go b/internal/db/tables_test.go index 200e168..d6d5f9a 100644 --- a/internal/db/tables_test.go +++ b/internal/db/tables_test.go @@ -141,6 +141,9 @@ func (suite *TablesTestSuite) TestCreateTable() { result, _ := db.ListTables(con, provider) convertedResult := utils.SliceOfPointersToSliceOfValues(result) assert.Contains(t, convertedResult, "test_create_table") + + err = db.CreateTable(con, "123456", nil) + assert.NotNil(t, err) } } diff --git a/internal/server_test.go b/internal/server_test.go index 4d10629..959b163 100644 --- a/internal/server_test.go +++ b/internal/server_test.go @@ -59,6 +59,12 @@ func TestInitDBAndServerFailing(t *testing.T) { listenCh := make(chan bool) app := fiber.New(fiber.Config{DisableStartupMessage: true}) + defer func() { + err := app.Shutdown() + if err != nil { + log.Fatal(err) + } + }() go func(app *fiber.App) { err := InitDBAndServer(app, lib.SQLITE3, ":memory:", 100000, listenCh)