Skip to content

Commit

Permalink
WIP - Add failing test
Browse files Browse the repository at this point in the history
This passes when commenting out the patch, but fails on when including it.
  • Loading branch information
AndrewSisley committed Jan 10, 2025
1 parent 43f2863 commit d8c0a5a
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions tests/integration/schema/updates/add/field/with_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ package field
import (
"testing"

"github.com/sourcenetwork/immutable"

"github.com/sourcenetwork/defradb/client"
testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

Expand All @@ -24,7 +27,6 @@ func TestSchemaUpdatesAddFieldSimple_WithExistingIndex(t *testing.T) {
Schema: `
type Users {
name: String @index
age: Int @index
}
`,
},
Expand All @@ -35,16 +37,42 @@ func TestSchemaUpdatesAddFieldSimple_WithExistingIndex(t *testing.T) {
]
`,
},
testUtils.Request{
Request: `query {
Users {
name
age
email
}
}`,
Results: map[string]any{
"Users": []map[string]any{},
// It is important to test that the index shows up in both the `GetIndexes` call,
// *and* the `GetCollections` call, as indexes are stored in multiple places and we had a bug
// where patching a schema would result in the index disappearing from one of those locations.
testUtils.GetIndexes{
ExpectedIndexes: []client.IndexDescription{
{
Name: "Users_name_ASC",
ID: 1,
Unique: false,
Fields: []client.IndexedFieldDescription{
{
Name: "name",
},
},
},
},
},
testUtils.GetCollections{
ExpectedResults: []client.CollectionDescription{
{
ID: 2,
Name: immutable.Some("Users"),
IsMaterialized: true,
Indexes: []client.IndexDescription{
{
Name: "Users_name_ASC",
ID: 1,
Unique: false,
Fields: []client.IndexedFieldDescription{
{
Name: "name",
},
},
},
},
},
},
},
},
Expand Down

0 comments on commit d8c0a5a

Please sign in to comment.