Files
kjol/go/dbutil/test_models_test.go

53 lines
1.5 KiB
Go

package dbutil
// Test-only model structs for builder and automapper tests.
// These are decoupled from the real models package so that tests
// do not break when application models change.
import (
"reflect"
"time"
"github.com/google/uuid"
)
// testUser mirrors a typical user table.
type testUser struct {
ID uuid.UUID `db:"id"`
Username string `db:"username"`
Email string `db:"email"`
FirstName string `db:"first_name"`
LastName string `db:"last_name"`
Password string `db:"password"`
LoginCount int32 `db:"login_count"`
Created time.Time `db:"created"`
Active bool `db:"active"`
}
// testSession mirrors a session / identity table.
type testSession struct {
ID uuid.UUID `db:"id"`
Key string `db:"key"`
UserID uuid.UUID `db:"user_id"`
OrgID *uuid.UUID `db:"org_id"`
Created time.Time `db:"created"`
UserAgent string `db:"user_agent"`
Revoked bool `db:"revoked"`
}
// testMembership mirrors an org-user / membership table.
type testMembership struct {
ID uuid.UUID `db:"id"`
UserID uuid.UUID `db:"user_id"`
OrgID uuid.UUID `db:"org_id"`
CreatedBy *uuid.UUID `db:"created_by"`
Joined time.Time `db:"joined"`
LoginCount int32 `db:"login_count"`
}
func init() {
Register(reflect.TypeOf(testUser{}), "test_user")
Register(reflect.TypeOf(testSession{}), "test_session")
Register(reflect.TypeOf(testMembership{}), "test_membership")
}