Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Nov 8, 2023
1 parent beb19b8 commit cfb235f
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion test/features/enums/enums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestEnums(t *testing.T) {
massert.Equal(t, expected, actual)
},
}, {
name: "many or",
name: "many or with and wrapper",
run: func(t *testing.T, client *PrismaClient, ctx cx) {
_, err := client.User.CreateOne(
User.Role.Set(RoleAdmin),
Expand Down Expand Up @@ -107,6 +107,60 @@ func TestEnums(t *testing.T) {
t.Fatalf("fail %s", err)
}

massert.Equal(t, []UserModel{
{
InnerUser: InnerUser{
ID: "123",
Role: RoleAdmin,
},
},
{
InnerUser: InnerUser{
ID: "789",
Role: RoleUser,
},
},
}, actual)
},
}, {
name: "many or direct",
run: func(t *testing.T, client *PrismaClient, ctx cx) {
_, err := client.User.CreateOne(
User.Role.Set(RoleAdmin),
User.ID.Set("123"),
).Exec(ctx)
if err != nil {
t.Fatalf("fail %s", err)
}

_, err = client.User.CreateOne(
User.Role.Set(RoleModerator),
User.ID.Set("456"),
).Exec(ctx)
if err != nil {
t.Fatalf("fail %s", err)
}

_, err = client.User.CreateOne(
User.Role.Set(RoleUser),
User.ID.Set("789"),
).Exec(ctx)
if err != nil {
t.Fatalf("fail %s", err)
}

actual, err := client.User.FindMany(
User.Or(
User.Role.Equals(RoleUser),
User.Role.Equals(RoleAdmin),
),
).OrderBy(
User.ID.Order(SortOrderAsc),
).Exec(ctx)
if err != nil {
t.Fatalf("fail %s", err)
}

massert.Equal(t, []UserModel{
{
InnerUser: InnerUser{
Expand Down

0 comments on commit cfb235f

Please sign in to comment.