hatecomputers.club/api/auth/auth_test.go

37 lines
817 B
Go
Raw Normal View History

2024-04-03 19:53:50 -04:00
package auth_test
import (
"database/sql"
"os"
2024-04-03 19:53:50 -04:00
"git.hatecomputers.club/hatecomputers/hatecomputers.club/api/types"
"git.hatecomputers.club/hatecomputers/hatecomputers.club/args"
"git.hatecomputers.club/hatecomputers/hatecomputers.club/database"
"git.hatecomputers.club/hatecomputers/hatecomputers.club/utils"
)
2024-04-03 19:53:50 -04:00
func setup() (*sql.DB, *types.RequestContext, func()) {
randomDb := utils.RandomId()
testDb := database.MakeConn(&randomDb)
database.Migrate(testDb)
2024-04-03 19:53:50 -04:00
context := &types.RequestContext{
DBConn: testDb,
Args: &args.Arguments{},
TemplateData: &(map[string]interface{}{}),
}
return testDb, context, func() {
testDb.Close()
os.Remove(randomDb)
}
}
/*
2024-04-03 19:53:50 -04:00
todo: test types key creation
+ api key attached to user
+ user session is unique
+ goLogin goes to page in cookie
*/