summaryrefslogtreecommitdiff
path: root/api/auth/auth_test.go
blob: a6c2a4518960e823bd8c02b68f5deac021a27385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package auth_test

import (
	"database/sql"
	"os"

	"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"
)

func setup() (*sql.DB, *types.RequestContext, func()) {
	randomDb := utils.RandomId()

	testDb := database.MakeConn(&randomDb)
	database.Migrate(testDb)

	context := &types.RequestContext{
		DBConn:       testDb,
		Args:         &args.Arguments{},
		TemplateData: &(map[string]interface{}{}),
	}

	return testDb, context, func() {
		testDb.Close()
		os.Remove(randomDb)
	}
}

/*
todo: test types key creation
+ api key attached to user
+ user session is unique
+ goLogin goes to page in cookie
*/