mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
71abc4f077
* test: machine * test: better naming
116 lines
2.2 KiB
Go
116 lines
2.2 KiB
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/caos/zitadel/internal/user/model"
|
|
)
|
|
|
|
func TestAppendDeactivatedEvent(t *testing.T) {
|
|
type args struct {
|
|
user *User
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
result *User
|
|
}{
|
|
{
|
|
name: "append deactivate event",
|
|
args: args{
|
|
user: &User{},
|
|
},
|
|
result: &User{State: int32(model.UserStateInactive)},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tt.args.user.appendDeactivatedEvent()
|
|
if tt.args.user.State != tt.result.State {
|
|
t.Errorf("got wrong result: expected: %v, actual: %v ", tt.result, tt.args.user)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestAppendReactivatedEvent(t *testing.T) {
|
|
type args struct {
|
|
user *User
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
result *User
|
|
}{
|
|
{
|
|
name: "append reactivate event",
|
|
args: args{
|
|
user: &User{},
|
|
},
|
|
result: &User{State: int32(model.UserStateActive)},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tt.args.user.appendReactivatedEvent()
|
|
if tt.args.user.State != tt.result.State {
|
|
t.Errorf("got wrong result: expected: %v, actual: %v ", tt.result, tt.args.user)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestAppendLockEvent(t *testing.T) {
|
|
type args struct {
|
|
user *User
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
result *User
|
|
}{
|
|
{
|
|
name: "append lock event",
|
|
args: args{
|
|
user: &User{},
|
|
},
|
|
result: &User{State: int32(model.UserStateLocked)},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tt.args.user.appendLockedEvent()
|
|
if tt.args.user.State != tt.result.State {
|
|
t.Errorf("got wrong result: expected: %v, actual: %v ", tt.result, tt.args.user)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestAppendUnlockEvent(t *testing.T) {
|
|
type args struct {
|
|
user *User
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
result *User
|
|
}{
|
|
{
|
|
name: "append unlock event",
|
|
args: args{
|
|
user: &User{},
|
|
},
|
|
result: &User{State: int32(model.UserStateActive)},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tt.args.user.appendUnlockedEvent()
|
|
if tt.args.user.State != tt.result.State {
|
|
t.Errorf("got wrong result: expected: %v, actual: %v ", tt.result, tt.args.user)
|
|
}
|
|
})
|
|
}
|
|
}
|