2024-04-03 19:53:50 -04:00
|
|
|
package auth_test
|
2024-04-03 18:22:19 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"os"
|
|
|
|
|
2024-04-03 19:53:50 -04:00
|
|
|
"git.hatecomputers.club/hatecomputers/hatecomputers.club/api/types"
|
2024-04-03 18:22:19 -04:00
|
|
|
"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()) {
|
2024-04-03 18:22:19 -04:00
|
|
|
randomDb := utils.RandomId()
|
|
|
|
|
|
|
|
testDb := database.MakeConn(&randomDb)
|
|
|
|
database.Migrate(testDb)
|
|
|
|
|
2024-04-03 19:53:50 -04:00
|
|
|
context := &types.RequestContext{
|
2024-04-03 18:22:19 -04:00
|
|
|
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
|
2024-04-03 18:22:19 -04:00
|
|
|
+ api key attached to user
|
|
|
|
+ user session is unique
|
|
|
|
+ goLogin goes to page in cookie
|
|
|
|
*/
|