-
Notifications
You must be signed in to change notification settings - Fork 124
/
utils_mysql_test.go
30 lines (25 loc) · 1015 Bytes
/
utils_mysql_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package db2struct
import (
"testing"
_ "github.com/go-sql-driver/mysql" // Initialize mysql driver
. "github.com/smartystreets/goconvey/convey"
)
const testMariadbUsername = "root"
const testMariadbPassword = ""
const testMariadbHost = "127.0.0.1"
const testMariadbPort = 3306
const testMariadbDatabase = "test"
func TestGetColumnsFromMysqlTable(t *testing.T) {
var testTable = "all_data_types"
columMap, err := GetColumnsFromMysqlTable(testMariadbUsername, testMariadbPassword, testMariadbHost, testMariadbPort, testMariadbDatabase, testTable)
Convey("Should be able to connect to test database and create columnMap", t, func() {
So(err, ShouldBeNil)
So(columMap, ShouldNotBeNil)
So(*columMap, ShouldNotBeEmpty)
})
columMap, err = GetColumnsFromMysqlTable(testMariadbUsername, testMariadbPassword, "doesnotexists", testMariadbPort, testMariadbDatabase, testTable)
Convey("Should get an error connecting to test database", t, func() {
So(err, ShouldNotBeNil)
So(columMap, ShouldBeNil)
})
}