Skip to content

Commit

Permalink
implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Sep 13, 2022
1 parent d6502df commit f0275c5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 111 deletions.
44 changes: 11 additions & 33 deletions tests/integration/collection/update/with_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
)

func TestUpdateWithFilter(t *testing.T) {
doc, err := client.NewDocFromJSON(
[]byte(
`{
"Name": "John",
"Age": 21
}`,
),
)
docStr := `{
"Name": "John",
"Age": 21
}`

doc, err := client.NewDocFromJSON([]byte(docStr))
if err != nil {
assert.Fail(t, err.Error())
}
Expand All @@ -38,12 +36,7 @@ func TestUpdateWithFilter(t *testing.T) {
{
Description: "Test update users with filter and invalid JSON",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand All @@ -56,16 +49,11 @@ func TestUpdateWithFilter(t *testing.T) {
},
},
},
ExpectedError: "cannot parse JSON: cannot parse object: cannot find opening '\"\" for object key; unparsed tail: \"Name: \\\"Eric\\\"\\n\\t\\t\\t\\t\\t\\t}\"",
ExpectedError: "cannot parse JSON: cannot parse object",
}, {
Description: "Test update users with filter and invalid updator",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand All @@ -80,12 +68,7 @@ func TestUpdateWithFilter(t *testing.T) {
}, {
Description: "Test update users with filter and patch updator (not implemented so no change)",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand Down Expand Up @@ -121,12 +104,7 @@ func TestUpdateWithFilter(t *testing.T) {
}, {
Description: "Test update users with filter",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand Down
44 changes: 11 additions & 33 deletions tests/integration/collection/update/with_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
)

func TestUpdateWithKey(t *testing.T) {
doc, err := client.NewDocFromJSON(
[]byte(
`{
"Name": "John",
"Age": 21
}`,
),
)
docStr := `{
"Name": "John",
"Age": 21
}`

doc, err := client.NewDocFromJSON([]byte(docStr))
if err != nil {
assert.Fail(t, err.Error())
}
Expand All @@ -36,12 +34,7 @@ func TestUpdateWithKey(t *testing.T) {
{
Description: "Test update users with key and invalid JSON",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand All @@ -54,16 +47,11 @@ func TestUpdateWithKey(t *testing.T) {
},
},
},
ExpectedError: "cannot parse JSON: cannot parse object: cannot find opening '\"\" for object key; unparsed tail: \"Name: \\\"Eric\\\"\\n\\t\\t\\t\\t\\t\\t}\"",
ExpectedError: "cannot parse JSON: cannot parse object",
}, {
Description: "Test update users with key and invalid updator",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand All @@ -78,12 +66,7 @@ func TestUpdateWithKey(t *testing.T) {
}, {
Description: "Test update users with key and patch updator (not implemented so no change)",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand Down Expand Up @@ -119,12 +102,7 @@ func TestUpdateWithKey(t *testing.T) {
}, {
Description: "Test update users with key",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`,
},
"users": {docStr},
},
CollectionCalls: map[string][]func(client.Collection) error{
"users": []func(c client.Collection) error{
Expand Down
66 changes: 21 additions & 45 deletions tests/integration/collection/update/with_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@ import (
)

func TestUpdateWithKeys(t *testing.T) {
doc1, err := client.NewDocFromJSON(
[]byte(
`{
"Name": "John",
"Age": 21
}`,
),
)
docStr1 := `{
"Name": "John",
"Age": 21
}`

doc1, err := client.NewDocFromJSON([]byte(docStr1))
if err != nil {
assert.Fail(t, err.Error())
}

doc2, err := client.NewDocFromJSON(
[]byte(
`{
"Name": "Sam",
"Age": 32
}`,
),
)
docStr2 := `{
"Name": "Sam",
"Age": 32
}`

doc2, err := client.NewDocFromJSON([]byte(docStr2))
if err != nil {
assert.Fail(t, err.Error())
}
Expand All @@ -49,13 +45,8 @@ func TestUpdateWithKeys(t *testing.T) {
Description: "Test update users with keys and invalid JSON",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`, `{
"Name": "Sam",
"Age": 32
}`,
docStr1,
docStr2,
},
},
CollectionCalls: map[string][]func(client.Collection) error{
Expand All @@ -69,18 +60,13 @@ func TestUpdateWithKeys(t *testing.T) {
},
},
},
ExpectedError: "cannot parse JSON: cannot parse object: cannot find opening '\"\" for object key; unparsed tail: \"Name: \\\"Eric\\\"\\n\\t\\t\\t\\t\\t\\t}\"",
ExpectedError: "cannot parse JSON: cannot parse object",
}, {
Description: "Test update users with keys and invalid updator",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`, `{
"Name": "Sam",
"Age": 32
}`,
docStr1,
docStr2,
},
},
CollectionCalls: map[string][]func(client.Collection) error{
Expand All @@ -97,13 +83,8 @@ func TestUpdateWithKeys(t *testing.T) {
Description: "Test update users with keys and patch updator (not implemented so no change)",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`, `{
"Name": "Sam",
"Age": 32
}`,
docStr1,
docStr2,
},
},
CollectionCalls: map[string][]func(client.Collection) error{
Expand Down Expand Up @@ -153,13 +134,8 @@ func TestUpdateWithKeys(t *testing.T) {
Description: "Test update users with keys",
Docs: map[string][]string{
"users": {
`{
"Name": "John",
"Age": 21
}`, `{
"Name": "Sam",
"Age": 32
}`,
docStr1,
docStr2,
},
},
CollectionCalls: map[string][]func(client.Collection) error{
Expand Down

0 comments on commit f0275c5

Please sign in to comment.