photoprism/internal/entity/user_fixtures.go

77 lines
1.5 KiB
Go
Raw Normal View History

package entity
type UserMap map[string]User
func (m UserMap) Get(name string) User {
if result, ok := m[name]; ok {
return result
}
return User{}
}
func (m UserMap) Pointer(name string) *User {
if result, ok := m[name]; ok {
return &result
}
return &User{}
}
var UserFixtures = UserMap{
"alice": {
ID: 5,
AddressID: 1,
UserUID: "uqxetse3cy5eo9z2",
UserName: "alice",
FullName: "Alice",
RoleAdmin: true,
RoleGuest: false,
UserDisabled: false,
PrimaryEmail: "alice@example.com",
},
"bob": {
ID: 7,
AddressID: 1,
UserUID: "uqxc08w3d0ej2283",
UserName: "bob",
FullName: "Bob",
RoleAdmin: false,
RoleGuest: false,
UserDisabled: false,
PrimaryEmail: "bob@example.com",
},
2021-08-12 20:29:15 +02:00
"friend": {
ID: 8,
AddressID: 1,
UserUID: "uqxqg7i1kperxvu7",
UserName: "friend",
FullName: "Guy Friend",
RoleAdmin: false,
RoleGuest: false,
RoleFriend: true,
UserDisabled: true,
PrimaryEmail: "friend@example.com",
},
2021-08-27 15:33:33 +02:00
"deleted": {
ID: 10000008,
AddressID: 1000000,
UserUID: "uqxqg7i1kperxvu8",
UserName: "deleted",
FullName: "Deleted User",
RoleAdmin: false,
RoleGuest: true,
RoleFriend: false,
UserDisabled: false,
PrimaryEmail: "",
DeletedAt: &deleteTime,
},
}
// CreateUserFixtures inserts known entities into the database for testing.
func CreateUserFixtures() {
for _, entity := range UserFixtures {
Db().Create(&entity)
}
}