Add UpdateSet, Relaxed in client, Fix tests
This commit is contained in:
16
find_test.go
16
find_test.go
@@ -76,33 +76,25 @@ func TestFind_Discriminator(t *testing.T) {
|
||||
|
||||
client := GetMongoClient()
|
||||
client.AddDefinition(store)
|
||||
|
||||
client.AddDefinition(offer)
|
||||
|
||||
// Save two offers with the similar name in different stores each.
|
||||
// Store str_1234 has OSRAM 1.
|
||||
ctx1 := context.Background()
|
||||
ctx1 = context.WithValue(ctx1, "account", "xxxxxx")
|
||||
ctx1 = context.WithValue(ctx1, "store", "str_1234")
|
||||
|
||||
// One offer in str_1234
|
||||
offer1 := map[string]any { "name": "OSRAM 1" }
|
||||
_, err = client.InsertOne(ctx1, "mydb", "offer", offer1)
|
||||
if err != nil { t.Fatalf("Failed to insertOne %#v", err) }
|
||||
|
||||
// The other in str_4321
|
||||
// Store str_4321 has OSRAM 2
|
||||
ctx2 := context.Background()
|
||||
ctx2 = context.WithValue(ctx2, "account", "xxxxxx")
|
||||
ctx2 = context.WithValue(ctx2, "store", "str_4321")
|
||||
offer2 := map[string]any { "name": "OSRAM 2" }
|
||||
_, err = client.InsertOne(ctx2, "mydb", "offer", offer2)
|
||||
if err != nil { t.Fatalf("Failed to insertOne %#v", err) }
|
||||
|
||||
// Now searching in store str_1234 for OSRAM should return only one
|
||||
|
||||
// Within store str_1234 searching for OSRAM should return one result
|
||||
filter := bson.M{"name": bson.M{"$regex": "OSRAM*"}}
|
||||
findResult, err := client.Find(ctx1, "mydb", "offer", filter, &FindOptions{
|
||||
Offset: int64(0),
|
||||
})
|
||||
findResult, err := client.Find(ctx1, "mydb", "offer", filter, &FindOptions{ Offset: int64(0) })
|
||||
if err != nil { t.Fatalf("Failed to find %#v", err) }
|
||||
|
||||
dataAny, hasData := findResult["data"]
|
||||
|
||||
Reference in New Issue
Block a user