Skip to content

Commit

Permalink
test findMany
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Oct 14, 2024
1 parent dba1e88 commit 89cc566
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions engine/queryFuncs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (

var s *Store

//func Test_NewDB(){}
//func Test_findOne(){}
//func Test_findById(){}

func Test_NewDB(t *testing.T) {
s = NewDB("tmptest.db")
if s == nil {
Expand Down Expand Up @@ -118,6 +122,20 @@ func Test_insertMany(t *testing.T) {
return nil
})
}

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

got := s.findMany(query)
exp := `[{"_id":1,"name":"adam1", "age": 21},{"_id":2,"name":"adam2", "age": 22},{"_id":3,"name":"adam3", "age": 23}]`

if got != exp {
t.Errorf("got %s\nexp %s", got, exp)
}

}

func Test_Close(t *testing.T) {
err := s.db.Close()

Expand Down

0 comments on commit 89cc566

Please sign in to comment.