Import sources from Kontor

This commit is contained in:
Thomas Peetz
2019-06-18 18:33:38 +02:00
parent fa3286c8e2
commit f326e994da
20 changed files with 1262 additions and 3 deletions
+50
View File
@@ -0,0 +1,50 @@
package dao
import (
"reflect"
"testing"
)
var baseDaoTestTable = []struct {
name string
typeName string
}{
{"Server", "string"},
{"Database", "string"},
{"MongoDb", "ptr"},
}
func TestCheckBaseDao(t *testing.T) {
d := BaseDAO{}
for index, testData := range baseDaoTestTable {
givenType := reflect.TypeOf(d).Field(index).Type.Kind().String()
if givenType != testData.typeName {
t.Fail()
}
}
}
func TestConnectDb(t *testing.T) {
d := BaseDAO{}
d.Connect()
if d.MongoDb == nil {
t.Fail()
}
}
func TestDatabasesConfig(t *testing.T) {
kalorienmanagerDb := KalorienmanagerDb
if kalorienmanagerDb.Server != "localhost" {
t.Fail()
}
if kalorienmanagerDb.Database != "kalorienmanager" {
t.Fail()
}
testDb := TestDb
if testDb.Server != "localhost" {
t.Fail()
}
if testDb.Database != "kalorienmanager_test" {
t.Fail()
}
}