remove obsolete subprojects
(cherry picked from commit e219932b17bf2b9776141828b3212ed210ffa251)
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
package tysc
|
||||
|
||||
import (
|
||||
"gitlab.thpeetz.de/kontor/kontor-go/pkg/dao"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
var positionModelTestTable = []struct {
|
||||
name string
|
||||
typeName string
|
||||
}{
|
||||
{"Id", "string"},
|
||||
{"Name", "string"},
|
||||
{"Description", "string"},
|
||||
{"Sport", "string"},
|
||||
{"Model", "string"},
|
||||
}
|
||||
|
||||
func TestPositionModel(t *testing.T) {
|
||||
m := Position{}
|
||||
if reflect.TypeOf(m).NumField() != len(positionModelTestTable) {
|
||||
t.Fail()
|
||||
}
|
||||
for index, testData := range positionModelTestTable {
|
||||
givenType := reflect.TypeOf(m).Field(index).Type.Kind().String()
|
||||
if givenType != testData.typeName {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListPositions(t *testing.T) {
|
||||
var (
|
||||
positionDao = PositionDAO{Db: dao.TestDb}
|
||||
)
|
||||
positions, err := positionDao.FindAll()
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
if len(positions) != 0 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestInsertPosition(t *testing.T) {
|
||||
var (
|
||||
positionDao = PositionDAO{Db: dao.TestDb}
|
||||
position = Position{}
|
||||
positions []Position
|
||||
)
|
||||
position.ID = bson.NewObjectId()
|
||||
position.Name = "test"
|
||||
err := positionDao.Insert(position)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
positions, err = positionDao.FindAll()
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
if len(positions) != 1 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpsertPosition(t *testing.T) {
|
||||
var (
|
||||
positionDao = PositionDAO{Db: dao.TestDb}
|
||||
position = Position{}
|
||||
)
|
||||
position.ID = bson.NewObjectId()
|
||||
position.Name = "test2"
|
||||
positionDao.Upsert(position)
|
||||
positions, err := positionDao.FindAll()
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
if len(positions) != 2 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeletePosition(t *testing.T) {
|
||||
var (
|
||||
positionDao = PositionDAO{Db: dao.TestDb}
|
||||
)
|
||||
positions, err := positionDao.FindAll()
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
for _, position := range positions {
|
||||
positionDao.Delete(position)
|
||||
}
|
||||
positions, err = positionDao.FindAll()
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
if len(positions) != 0 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user