Skip to content

Commit

Permalink
test(documents): Add basic key checks to integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjholm committed Jul 19, 2021
1 parent a60dff8 commit 5c0ad88
Showing 1 changed file with 78 additions and 8 deletions.
86 changes: 78 additions & 8 deletions tests/plugins/document/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func GetTests(docPlugin sdk.DocumentService) {
doc, err := docPlugin.Get(&UserKey1)
Expect(err).ShouldNot(HaveOccurred())
Expect(doc).ToNot(BeNil())
Expect(doc.Key).To(Equal(&UserKey1))
Expect(doc.Content["email"]).To(BeEquivalentTo(UserItem1["email"]))
})
})
Expand All @@ -336,6 +337,7 @@ func GetTests(docPlugin sdk.DocumentService) {
doc, err := docPlugin.Get(&Customer1.Orders[0].Key)
Expect(err).ShouldNot(HaveOccurred())
Expect(doc).ToNot(BeNil())
Expect(doc.Key).To(Equal(&Customer1.Orders[0].Key))
Expect(doc.Content).To(BeEquivalentTo(Customer1.Orders[0].Content))
})
})
Expand Down Expand Up @@ -495,6 +497,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result).ToNot(BeNil())
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(3))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: '', exp: []", func() {
Expand All @@ -508,6 +514,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents[0].Content["email"]).To(BeEquivalentTo(Customer1.Content["email"]))
Expect(result.Documents[1].Content["email"]).To(BeEquivalentTo(Customer2.Content["email"]))
Expect(result.PagingToken).To(BeNil())

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: '', exp: [country == US]", func() {
Expand All @@ -523,6 +533,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents).To(HaveLen(1))
Expect(result.Documents[0].Content["email"]).To(BeEquivalentTo(Customer2.Content["email"]))
Expect(result.PagingToken).To(BeNil())

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: '', exp: [country == US, age > 40]", func() {
Expand Down Expand Up @@ -554,6 +568,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[0].Content["testName"]))
Expect(result.Documents[1].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[1].Content["testName"]))
Expect(result.Documents[2].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[2].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: orders, exps: [number == 1]", func() {
Expand All @@ -573,6 +591,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents).To(HaveLen(2))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[0].Content["testName"]))
Expect(result.Documents[1].Content["testName"]).To(BeEquivalentTo(Customer2.Orders[0].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, key1}, subcol: orders, exps: [number == 1]", func() {
Expand All @@ -591,6 +613,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(1))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[0].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: orders, exps: [number > 1]", func() {
Expand All @@ -608,6 +634,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result).ToNot(BeNil())
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(3))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, key1}, subcol: orders, exps: [number > 1]", func() {
Expand All @@ -627,6 +657,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents).To(HaveLen(2))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[1].Content["testName"]))
Expect(result.Documents[1].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[2].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: orders, exps: [number < 1]", func() {
Expand All @@ -644,6 +678,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result).ToNot(BeNil())
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(0))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, key1}, subcol: orders, exps: [number < 1]", func() {
Expand Down Expand Up @@ -678,6 +716,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result).ToNot(BeNil())
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(5))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, key1}, subcol: orders, exps: [number >= 1]", func() {
Expand All @@ -695,6 +737,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result).ToNot(BeNil())
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(3))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, nil}, subcol: orders, exps: [number <= 1]", func() {
Expand All @@ -714,6 +760,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents).To(HaveLen(2))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[0].Content["testName"]))
Expect(result.Documents[1].Content["testName"]).To(BeEquivalentTo(Customer2.Orders[0].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {customers, key1}, subcol: orders, exps: [number <= 1]", func() {
Expand All @@ -732,6 +782,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(1))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[0].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key {customers, nil}, subcol: orders, exps: [type startsWith scooter]", func() {
Expand All @@ -751,6 +805,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.Documents).To(HaveLen(2))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[2].Content["testName"]))
Expect(result.Documents[1].Content["testName"]).To(BeEquivalentTo(Customer2.Orders[1].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key {customers, key1}, subcol: orders, exps: [type startsWith bike/road]", func() {
Expand All @@ -769,6 +827,10 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Documents).To(HaveLen(1))
Expect(result.Documents[0].Content["testName"]).To(BeEquivalentTo(Customer1.Orders[2].Content["testName"]))

for _, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
}
})
})
When("key: {items, nil}, subcol: '', exp: [], limit: 10", func() {
Expand All @@ -786,7 +848,8 @@ func QueryTests(docPlugin sdk.DocumentService) {

// Ensure values are unique
dataMap := make(map[string]string)
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
dataMap[val] = val
}
Expand All @@ -798,7 +861,8 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.PagingToken).To(BeNil())

// Ensure values are unique
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
if _, found := dataMap[val]; found {
Expect("matching value").ShouldNot(HaveOccurred())
Expand All @@ -824,7 +888,8 @@ func QueryTests(docPlugin sdk.DocumentService) {

// Ensure values are unique
dataMap := make(map[string]string)
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
dataMap[val] = val
}
Expand All @@ -836,7 +901,8 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.PagingToken).ToNot(BeEmpty())

// Ensure values are unique
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
if _, found := dataMap[val]; found {
Expect("matching value").ShouldNot(HaveOccurred())
Expand All @@ -862,7 +928,8 @@ func QueryTests(docPlugin sdk.DocumentService) {

// Ensure values are unique
dataMap := make(map[string]string)
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
dataMap[val] = val
}
Expand All @@ -874,7 +941,8 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.PagingToken).To(BeNil())

// Ensure values are unique
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
if _, found := dataMap[val]; found {
Expect("matching value").ShouldNot(HaveOccurred())
Expand All @@ -897,7 +965,8 @@ func QueryTests(docPlugin sdk.DocumentService) {

// Ensure values are unique
dataMap := make(map[string]string)
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
dataMap[val] = val
}
Expand All @@ -909,7 +978,8 @@ func QueryTests(docPlugin sdk.DocumentService) {
Expect(result.PagingToken).ToNot(BeEmpty())

// Ensure values are unique
for i := range result.Documents {
for i, d := range result.Documents {
Expect(d.Key).ToNot(BeNil())
val := fmt.Sprintf("%v", result.Documents[i].Content["letter"])
if _, found := dataMap[val]; found {
Expect("matching value").ShouldNot(HaveOccurred())
Expand Down

0 comments on commit 5c0ad88

Please sign in to comment.