-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error when trying to save value to relation field
- Loading branch information
1 parent
c60ceee
commit 8cf0cb0
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/integration/collection/create/one_to_many/simple_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package create | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/sourcenetwork/defradb/client" | ||
testUtils "github.com/sourcenetwork/defradb/tests/integration/collection" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateSaveErrorsGivenValueInRelationField(t *testing.T) { | ||
doc, err := client.NewDocFromJSON( | ||
[]byte( | ||
`{ | ||
"Name": "Painted House", | ||
"Author": "ValueDoesntMatter" | ||
}`, | ||
), | ||
) | ||
if err != nil { | ||
assert.Fail(t, err.Error()) | ||
} | ||
|
||
test := testUtils.TestCase{ | ||
CollectionCalls: map[string][]func(client.Collection) error{ | ||
"book": []func(c client.Collection) error{ | ||
func(c client.Collection) error { | ||
return c.Save(context.Background(), doc) | ||
}, | ||
}, | ||
}, | ||
ExpectedError: "The given field does not exist", | ||
} | ||
|
||
executeTestCase(t, test) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package create | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration/collection" | ||
) | ||
|
||
var schema = (` | ||
type book { | ||
Name: String | ||
Rating: Float | ||
Author: author | ||
} | ||
type author { | ||
Name: String | ||
Age: Int | ||
Verified: Boolean | ||
Published: [book] | ||
} | ||
`) | ||
|
||
func executeTestCase(t *testing.T, test testUtils.TestCase) { | ||
testUtils.ExecuteQueryTestCase(t, schema, test) | ||
} |