Skip to content

Commit

Permalink
test: should hit 90% now ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
kareemmahlees committed Feb 16, 2024
1 parent 1a48898 commit 50f850f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/db/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/db/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
6 changes: 6 additions & 0 deletions internal/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 50f850f

Please sign in to comment.