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
-103
View File
@@ -1,103 +0,0 @@
package auth
import (
"gitlab.thpeetz.de/kontor/kontor-go/pkg/dao"
"reflect"
"testing"
"gopkg.in/mgo.v2/bson"
)
var sessionModelTestTable = []struct {
name string
typeName string
}{
{"Id", "string"},
{"Username", "string"},
{"IsAdmin", "bool"},
{"Model", "string"},
}
func TestSessionModel(t *testing.T) {
m := Session{}
if reflect.TypeOf(m).NumField() != len(sessionModelTestTable) {
t.Fail()
}
for index, testData := range sessionModelTestTable {
givenType := reflect.TypeOf(m).Field(index).Type.Kind().String()
if givenType != testData.typeName {
t.Fail()
}
}
}
func TestListSessions(t *testing.T) {
var (
sessionDao = SessionDAO{Db: dao.TestDb}
)
sessions, err := sessionDao.FindAll()
if err != nil {
t.Fail()
}
if sessions != nil {
t.Fail()
}
}
func TestInsertSession(t *testing.T) {
var (
sessionDao = SessionDAO{Db: dao.TestDb}
session = Session{}
sessions []Session
)
session.ID = bson.NewObjectId()
session.Username = "test"
err := sessionDao.Insert(session)
if err != nil {
t.Fail()
}
sessions, err = sessionDao.FindAll()
if err != nil {
t.Fail()
}
if len(sessions) != 1 {
t.Fail()
}
}
func TestUpsertSession(t *testing.T) {
var (
sessionDao = SessionDAO{Db: dao.TestDb}
session = Session{}
)
session.ID = bson.NewObjectId()
session.Username = "test2"
sessionDao.Upsert(session)
sessions, err := sessionDao.FindAll()
if err != nil {
t.Fail()
}
if len(sessions) != 2 {
t.Fail()
}
}
func TestDeleteSession(t *testing.T) {
var (
sessionDao = SessionDAO{Db: dao.TestDb}
)
sessions, err := sessionDao.FindAll()
if err != nil {
t.Fail()
}
for _, session := range sessions {
sessionDao.Delete(session)
}
sessions, err = sessionDao.FindAll()
if err != nil {
t.Fail()
}
if len(sessions) != 0 {
t.Fail()
}
}