diff --git a/tests/integration/schema/simple_test.go b/tests/integration/schema/simple_test.go index 9e169e6178..dd7e8ce2cd 100644 --- a/tests/integration/schema/simple_test.go +++ b/tests/integration/schema/simple_test.go @@ -16,6 +16,7 @@ import ( "github.com/sourcenetwork/immutable" "github.com/sourcenetwork/defradb/client" + "github.com/sourcenetwork/defradb/client/request" testUtils "github.com/sourcenetwork/defradb/tests/integration" ) @@ -28,6 +29,16 @@ func TestSchemaSimpleCreatesSchemaGivenEmptyType(t *testing.T) { Schema: ` type Users {} `, + ExpectedResults: []client.CollectionDescription{ + { + Name: immutable.Some("Users"), + Fields: []client.CollectionFieldDescription{ + { + Name: request.DocIDFieldName, + }, + }, + }, + }, }, testUtils.IntrospectionRequest{ Request: ` diff --git a/tests/integration/test_case.go b/tests/integration/test_case.go index 487641c5ec..4536c0cd0a 100644 --- a/tests/integration/test_case.go +++ b/tests/integration/test_case.go @@ -81,6 +81,15 @@ type SchemaUpdate struct { // The schema update. Schema string + // Optionally, the expected results. + // + // Each item will be compared individually, if ID, RootID, SchemaVersionID or Fields on the + // expected item are default they will not be compared with the actual. + // + // Assertions on Indexes and Sources will not distinguish between nil and empty (in order + // to allow their ommission in most cases). + ExpectedResults []client.CollectionDescription + // Any error expected from the action. Optional. // // String can be a partial, and the test will pass if an error is returned that diff --git a/tests/integration/utils2.go b/tests/integration/utils2.go index e808a81572..42ab28c04c 100644 --- a/tests/integration/utils2.go +++ b/tests/integration/utils2.go @@ -1000,10 +1000,14 @@ func updateSchema( action SchemaUpdate, ) { for _, node := range getNodes(action.NodeID, s.nodes) { - _, err := node.AddSchema(s.ctx, action.Schema) + results, err := node.AddSchema(s.ctx, action.Schema) expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError) assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) + + if action.ExpectedResults != nil { + assertCollectionDescriptions(s, action.ExpectedResults, results) + } } // If the schema was updated we need to refresh the collection definitions.