Skip to content

Commit

Permalink
more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Oct 14, 2024
1 parent 89cc566 commit af9016c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions engine/queryFuncs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,29 @@ func Test_insertMany(t *testing.T) {
}

func Test_findMany(t *testing.T) {
json := `{"collection":"insertTest", "action":"findMany"}` //,"match":{"name":"adam"}
query := gjson.Parse(json)

got := s.findMany(query)
got := s.findMany(gjson.Parse(`{"collection":"insertTest", "action":"findMany"}`))
exp := `[{"_id":1,"name":"adam1", "age": 21},{"_id":2,"name":"adam2", "age": 22},{"_id":3,"name":"adam3", "age": 23}]`
if got != exp {
t.Errorf(Red+"got %s\nexp %s"+Reset, got, exp)
}

got = s.findMany(gjson.Parse(`{"collection":"insertTest", "action":"findMany", "limit": 1}`))
exp = `[{"_id":1,"name":"adam1", "age": 21}]`
if got != exp {
t.Errorf(Red+"got %s\nexp %s"+Reset, got, exp)
}

got = s.findMany(gjson.Parse(`{"collection":"insertTest", "action":"findMany", "limit": 1, "skip", 2}`))
exp = `[{"_id":3,"name":"adam3", "age": 23}]`
if got != exp {
t.Errorf(Red+"got %s\nexp %s"+Reset, got, exp)
}

got = s.findMany(gjson.Parse(`{"collection":"insertTest", "action":"findMany", "skip", 3}`))
exp = `[]`
if got != exp {
t.Errorf("got %s\nexp %s", got, exp)
t.Errorf(Red+"got %s\nexp %s"+Reset, got, exp)
}

}
Expand Down

0 comments on commit af9016c

Please sign in to comment.