Skip to content

Commit

Permalink
test(i): Update mut. tests to make use of mut. system (sourcenetwork#…
Browse files Browse the repository at this point in the history
…1853)

## Relevant issue(s)

Resolves sourcenetwork#1851

## Description

Updates the mutation tests to make use of mutation system.

A handful of collection based tests still exist, as they test stuff that
does not yet have support in the new mutation test system (filter,
UpdateWithKey(s)). These should be moved later when such support is
added.

Similarly, the new mutation system does not yet support txns, so the gql
request based txn tests remain as gql tests for now.

sourcenetwork#1703 Was linked up to
tests in this PR, and
sourcenetwork#1852 and
sourcenetwork#1854 were discovered.
Fixing them is out of scope here.

Update: It does now fix a bug in the http client collection.Create[Many]
functions, as it was easier to fix than to open a ticket.
  • Loading branch information
AndrewSisley authored Sep 14, 2023
1 parent 3091ece commit 9524a41
Show file tree
Hide file tree
Showing 21 changed files with 851 additions and 1,601 deletions.
3 changes: 3 additions & 0 deletions docs/data_format_changes/i1851-no-change-tests-updated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make existing mutation tests use mutation test system

This is not a breaking change, tests were changed from using gql requests to CreateDoc and UpdateDoc actions, meaning the point at which the change detector split setup/assert shifted.
14 changes: 14 additions & 0 deletions http/client_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ func (c *Collection) SchemaID() string {
func (c *Collection) Create(ctx context.Context, doc *client.Document) error {
methodURL := c.http.baseURL.JoinPath("collections", c.desc.Name)

// We must call this here, else the doc key on the given object will not match
// that of the document saved in the database
err := doc.RemapAliasFieldsAndDockey(c.Description().Schema.Fields)
if err != nil {
return err
}

body, err := doc.String()
if err != nil {
return err
Expand All @@ -79,6 +86,13 @@ func (c *Collection) CreateMany(ctx context.Context, docs []*client.Document) er

var docMapList []json.RawMessage
for _, doc := range docs {
// We must call this here, else the doc key on the given object will not match
// that of the document saved in the database
err := doc.RemapAliasFieldsAndDockey(c.Description().Schema.Fields)
if err != nil {
return err
}

docMap, err := documentJSON(doc)
if err != nil {
return err
Expand Down
47 changes: 0 additions & 47 deletions tests/integration/collection/create/one_to_many/simple_test.go

This file was deleted.

36 changes: 0 additions & 36 deletions tests/integration/collection/create/one_to_many/utils.go

This file was deleted.

127 changes: 0 additions & 127 deletions tests/integration/collection/create/one_to_one/save_test.go

This file was deleted.

36 changes: 0 additions & 36 deletions tests/integration/collection/create/one_to_one/utils.go

This file was deleted.

Loading

0 comments on commit 9524a41

Please sign in to comment.