-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83978dd
commit e012e0a
Showing
3 changed files
with
104 additions
and
13 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
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
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 |
---|---|---|
|
@@ -534,6 +534,93 @@ func TestSchemaMigrationQueryMigratesAcrossMultipleVersionsBeforePatches(t *test | |
testUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestSchemaMigrationQueryMigratesAcrossMultipleVersionsBeforePatchesWrongOrder(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Description: "Test schema migration, multiple migrations before patch", | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Users { | ||
name: String | ||
} | ||
`, | ||
}, | ||
testUtils.CreateDoc{ | ||
Doc: `{ | ||
"name": "John" | ||
}`, | ||
}, | ||
testUtils.ConfigureMigration{ | ||
// Declare the migration from v2=>v3 before declaring the migration from v1=>v2 | ||
LensConfig: client.LensConfig{ | ||
SourceSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", | ||
DestinationSchemaVersionID: "bafkreifiai7ukztmfavmicyq6hummnwpueq475ddn6m5wsbjhhpjtp6fcy", | ||
Lens: model.Lens{ | ||
Lenses: []model.LensModule{ | ||
{ | ||
Path: lenses.SetDefaultModulePath, | ||
Arguments: map[string]any{ | ||
"dst": "email", | ||
"value": "[email protected]", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
testUtils.ConfigureMigration{ | ||
LensConfig: client.LensConfig{ | ||
SourceSchemaVersionID: "bafkreig3zt63qt7bkji47etyu2sqtzroa3tcfdxgwqc3ka2ijy63refq3a", | ||
DestinationSchemaVersionID: "bafkreia4m6sn2rfypj2velvwpyude22fcb5jyfzum2eh3cdzg4a3myj5nu", | ||
Lens: model.Lens{ | ||
Lenses: []model.LensModule{ | ||
{ | ||
Path: lenses.SetDefaultModulePath, | ||
Arguments: map[string]any{ | ||
"dst": "verified", | ||
"value": true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
testUtils.SchemaPatch{ | ||
Patch: ` | ||
[ | ||
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "verified", "Kind": "Boolean"} } | ||
] | ||
`, | ||
}, | ||
testUtils.SchemaPatch{ | ||
Patch: ` | ||
[ | ||
{ "op": "add", "path": "/Users/Fields/-", "value": {"Name": "email", "Kind": "String"} } | ||
] | ||
`, | ||
}, | ||
testUtils.Request{ | ||
Request: `query { | ||
Users { | ||
name | ||
verified | ||
} | ||
}`, | ||
Results: []map[string]any{ | ||
{ | ||
"name": "John", | ||
"verified": true, | ||
"email": "[email protected]", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
// This test is important as it tests that orphan migrations do not block the fetcher(s) | ||
// from functioning. | ||
// | ||
|