remove obsolete subprojects

(cherry picked from commit e219932b17bf2b9776141828b3212ed210ffa251)
This commit is contained in:
2026-01-25 20:26:10 +01:00
parent 44fac3f471
commit a196f25526
587 changed files with 0 additions and 31031 deletions
-99
View File
@@ -1,99 +0,0 @@
package library
import (
"gitlab.thpeetz.de/kontor/kontor-go/pkg/dao"
"reflect"
"testing"
"gopkg.in/mgo.v2/bson"
)
var authorModelTestTable = []struct {
name string
typeName string
}{
{"Id", "string"},
{"Name", "string"},
{"Model", "string"},
}
func TestAuthorModel(t *testing.T) {
m := Author{}
if reflect.TypeOf(m).NumField() != len(authorModelTestTable) {
t.Fail()
}
for index, testData := range authorModelTestTable {
givenType := reflect.TypeOf(m).Field(index).Type.Kind().String()
if givenType != testData.typeName {
t.Fail()
}
}
}
func TestListAuthors(t *testing.T) {
var (
authorDao = AuthorDAO{Db: dao.TestDb}
)
authors, err := authorDao.FindAll()
if err != nil {
t.Fail()
}
if len(authors) != 0 {
t.Fail()
}
}
func TestInsertAuthor(t *testing.T) {
var (
authorDao = AuthorDAO{Db: dao.TestDb}
author = Author{}
authors []Author
)
author.ID = bson.NewObjectId()
author.Name = "Packt Publishing"
err := authorDao.Insert(author)
if err != nil {
t.Fail()
}
authors, err = authorDao.FindAll()
if len(authors) != 1 {
t.Fail()
}
}
func TestUpsertAuthor(t *testing.T) {
var (
authorDao = AuthorDAO{Db: dao.TestDb}
)
var author = Author{}
author.ID = bson.NewObjectId()
author.Name = "Hansa Verlag"
authorDao.Upsert(author)
authors, err := authorDao.FindAll()
if err != nil {
t.Fail()
}
if len(authors) != 2 {
t.Fail()
}
}
func TestDeleteAuthor(t *testing.T) {
var (
authorDao = AuthorDAO{Db: dao.TestDb}
)
authors, err := authorDao.FindAll()
if err != nil {
t.Fail()
}
for _, author := range authors {
authorDao.Delete(author)
}
authors, err = authorDao.FindAll()
if err != nil {
t.Fail()
}
if len(authors) != 0 {
t.Fail()
}
}