2021-08-10 12:30:04 +02:00
|
|
|
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-10 12:30:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateUserFixtures inserts known entities into the database for testing.
|
|
|
|
func CreateUserFixtures() {
|
|
|
|
for _, entity := range UserFixtures {
|
|
|
|
Db().Create(&entity)
|
|
|
|
}
|
|
|
|
}
|