forked from mirrors/homebox
align types with new db schema
This commit is contained in:
parent
63cfeffc4d
commit
b83505104a
30 changed files with 1491 additions and 263 deletions
|
@ -23,10 +23,11 @@ type UserIn struct {
|
|||
// in the database. It should to create users from an API unless the user has
|
||||
// rights to create SuperUsers. For regular user in data use the UserIn struct.
|
||||
type UserCreate struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
IsSuperuser bool `json:"isSuperuser"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
IsSuperuser bool `json:"isSuperuser"`
|
||||
GroupID uuid.UUID `json:"groupID"`
|
||||
}
|
||||
|
||||
func (u *UserCreate) Validate() error {
|
||||
|
@ -39,20 +40,12 @@ func (u *UserCreate) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type UserOut struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"-"`
|
||||
IsSuperuser bool `json:"isSuperuser"`
|
||||
}
|
||||
|
||||
// IsNull is a proxy call for `usr.Id == uuid.Nil`
|
||||
func (usr *UserOut) IsNull() bool {
|
||||
return usr.ID == uuid.Nil
|
||||
}
|
||||
|
||||
type UserUpdate struct {
|
||||
Name *string `json:"name"`
|
||||
Email *string `json:"email"`
|
||||
}
|
||||
|
||||
type UserRegistration struct {
|
||||
User UserIn `json:"user"`
|
||||
GroupName string `json:"groupName"`
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package types
|
|||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUserCreate_Validate(t *testing.T) {
|
||||
|
@ -64,13 +61,3 @@ func TestUserCreate_Validate(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserOut_IsNull(t *testing.T) {
|
||||
nullUser := UserOut{}
|
||||
|
||||
assert.True(t, nullUser.IsNull())
|
||||
|
||||
nullUser.ID = uuid.New()
|
||||
|
||||
assert.False(t, nullUser.IsNull())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue