-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Standardise schema migration
CLI errors
#1682
Merged
AndrewSisley
merged 8 commits into
sourcenetwork:develop
from
AndrewSisley:1673-cli-lens-capitalization
Jul 21, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cc701d2
Use std arg error string for migration set
AndrewSisley c2ca2a9
Include max and actual arg count in schema err
AndrewSisley 9e173c0
Move arg errors into Run func
AndrewSisley 0f836c0
Error on unknown cfg properties
AndrewSisley 8ce5a42
Add migration CLI tests
AndrewSisley 862f91b
Move arg error into Run func
AndrewSisley 7df8194
Use std arg error string for migration get
AndrewSisley 0e86ebd
Add schema migration get tests
AndrewSisley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
110 changes: 110 additions & 0 deletions
110
tests/integration/cli/client_schema_migration_get_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,110 @@ | ||
// Copyright 2023 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 clitest | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/sourcenetwork/defradb/tests/lenses" | ||
) | ||
|
||
func TestSchemaMigrationGet_GivenOneArg_ShouldReturnError(t *testing.T) { | ||
conf := NewDefraNodeDefaultConfig(t) | ||
stopDefra := runDefraNode(t, conf) | ||
|
||
_, stderr := runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "get", | ||
"notAnArg", | ||
}) | ||
_ = stopDefra() | ||
|
||
assertContainsSubstring(t, stderr, "too many arguments. Max: 0, Actual: 1") | ||
} | ||
|
||
func TestSchemaMigrationGet_GivenNoMigrations_ShouldSucceed(t *testing.T) { | ||
conf := NewDefraNodeDefaultConfig(t) | ||
stopDefra := runDefraNode(t, conf) | ||
|
||
stdout, _ := runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "get", | ||
}) | ||
_ = stopDefra() | ||
|
||
assertContainsSubstring(t, stdout, `{"data":{"configuration":[]}}`) | ||
} | ||
|
||
func TestSchemaMigrationGet_GivenEmptyMigrationObj_ShouldSucceed(t *testing.T) { | ||
islamaliev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
conf := NewDefraNodeDefaultConfig(t) | ||
stopDefra := runDefraNode(t, conf) | ||
|
||
stdout, _ := runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "set", | ||
"bae123", "bae456", "{}", | ||
}) | ||
assertContainsSubstring(t, stdout, "success") | ||
|
||
stdout, _ = runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "get", | ||
}) | ||
_ = stopDefra() | ||
|
||
assertContainsSubstring(t, stdout, | ||
`{"data":{"configuration":[{"SourceSchemaVersionID":"bae123","DestinationSchemaVersionID":"bae456","Lenses":null}]}}`, | ||
) | ||
} | ||
|
||
func TestSchemaMigrationGet_GivenEmptyMigration_ShouldSucceed(t *testing.T) { | ||
conf := NewDefraNodeDefaultConfig(t) | ||
stopDefra := runDefraNode(t, conf) | ||
|
||
stdout, _ := runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "set", | ||
"bae123", "bae456", `{"lenses": []}`, | ||
}) | ||
assertContainsSubstring(t, stdout, "success") | ||
|
||
stdout, _ = runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "get", | ||
}) | ||
_ = stopDefra() | ||
|
||
assertContainsSubstring(t, stdout, | ||
`{"data":{"configuration":[{"SourceSchemaVersionID":"bae123","DestinationSchemaVersionID":"bae456","Lenses":[]}]}}`, | ||
) | ||
} | ||
|
||
func TestSchemaMigrationGet_GivenMigration_ShouldSucceed(t *testing.T) { | ||
conf := NewDefraNodeDefaultConfig(t) | ||
stopDefra := runDefraNode(t, conf) | ||
|
||
stdout, _ := runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "set", | ||
"bae123", "bae456", | ||
fmt.Sprintf(`{"lenses": [{"path":"%s","arguments":{"dst":"verified","value":true}}]}`, lenses.SetDefaultModulePath), | ||
}) | ||
assertContainsSubstring(t, stdout, "success") | ||
|
||
stdout, _ = runDefraCommand(t, conf, []string{ | ||
"client", "schema", "migration", "get", | ||
}) | ||
_ = stopDefra() | ||
|
||
assertContainsSubstring(t, stdout, | ||
`{"data":{"configuration":[{"SourceSchemaVersionID":"bae123","DestinationSchemaVersionID":"bae456","Lenses":[`+ | ||
fmt.Sprintf( | ||
`{"Path":"%s",`, | ||
lenses.SetDefaultModulePath, | ||
)+ | ||
`"Inverse":false,"Arguments":{"dst":"verified","value":true}}`+ | ||
`]}]}}`, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: what caused this bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More tests == even slower :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a bunch of CLI tests