-
Notifications
You must be signed in to change notification settings - Fork 2
/
model.go
42 lines (35 loc) · 1.02 KB
/
model.go
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
37
38
39
40
41
42
package apitest
import (
"context"
eauth "encore.dev/beta/auth"
"github.com/ardanlabs/encore/app/sdk/auth"
"github.com/ardanlabs/encore/business/domain/homebus"
"github.com/ardanlabs/encore/business/domain/productbus"
"github.com/ardanlabs/encore/business/domain/userbus"
)
// User extends the dbtest user for app test support.
type User struct {
userbus.User
Products []productbus.Product
Homes []homebus.Home
Token string
}
// SeedData represents users for app tests.
type SeedData struct {
Users []User
Admins []User
}
// Table represent fields needed for running an app test.
type Table struct {
Name string
Token string
ExpResp any
ExcFunc func(ctx context.Context) any
CmpFunc func(got any, exp any) string
}
// AuthParams provides access to the authorization header.
type AuthParams struct {
Authorization string `header:"Authorization"`
}
// AuthHandler represents a function that can perform authentication.
type AuthHandler func(ctx context.Context, ap *AuthParams) (eauth.UID, *auth.Claims, error)