Skip to content

Commit 0ac4088

Browse files
committed
feat: improve coverage of TableExists
1 parent 77a9007 commit 0ac4088

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/models_tests/models_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/uc-cdis/cohort-middleware/tests"
1515
"github.com/uc-cdis/cohort-middleware/utils"
1616
"github.com/uc-cdis/cohort-middleware/version"
17+
"gorm.io/gorm"
1718
)
1819

1920
var testSourceId = tests.GetTestSourceId()
@@ -1603,3 +1604,16 @@ func TestExecSQLError(t *testing.T) {
16031604
t.Errorf("Panic should have occurred due to SQL Error")
16041605

16051606
}
1607+
1608+
func TestTableExists(t *testing.T) {
1609+
setUp(t)
1610+
session := tests.GetResultsDataSource().Db.Session(&gorm.Session{})
1611+
exists := utils.TableExists(session, tests.GetResultsDataSource().Schema+".cohort")
1612+
if !exists {
1613+
t.Errorf("Expected 'cohort' table to exist")
1614+
}
1615+
exists = utils.TableExists(session, "cohort_non_existing_table")
1616+
if exists {
1617+
t.Errorf("Did NOT expect 'cohort_non_existing_table' to exist")
1618+
}
1619+
}

0 commit comments

Comments
 (0)