38 lines
		
	
	
		
			815 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			815 B
		
	
	
	
		
			Go
		
	
	
	
package api_test
 | 
						|
 | 
						|
import (
 | 
						|
	"database/sql"
 | 
						|
	"os"
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"git.hatecomputers.club/hatecomputers/hatecomputers.club/api"
 | 
						|
	"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, *api.RequestContext, func()) {
 | 
						|
	randomDb := utils.RandomId()
 | 
						|
 | 
						|
	testDb := database.MakeConn(&randomDb)
 | 
						|
	database.Migrate(testDb)
 | 
						|
 | 
						|
	context := &api.RequestContext{
 | 
						|
		DBConn:       testDb,
 | 
						|
		Args:         &args.Arguments{},
 | 
						|
		TemplateData: &(map[string]interface{}{}),
 | 
						|
	}
 | 
						|
 | 
						|
	return testDb, context, func() {
 | 
						|
		testDb.Close()
 | 
						|
		os.Remove(randomDb)
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
todo: test api key creation
 | 
						|
+ api key attached to user
 | 
						|
+ user session is unique
 | 
						|
+ goLogin goes to page in cookie
 | 
						|
*/
 |