-
Notifications
You must be signed in to change notification settings - Fork 129
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: unexpected error with --select-tag and multiple files #571
Merged
Conversation
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
When running sync with multiple files and --select-tag, deck simply appends the existing _info.select_tags of the various files. If the same tag(s) are present in the files, these are appended together and making deck fail because tags passed via the command flag and the ones coming from the files are expected to match, but the way files are merged may cause duplicates, hence the unexpected failure. This removes duplicates from the _info.select_tags resulted from the merged files.
rainest
suggested changes
Jan 26, 2022
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.
Can you add a case to
Lines 11 to 67 in d0573b4
func TestDetermineSelectorTag(t *testing.T) { | |
type args struct { | |
dumpConfig dump.Config | |
fileContent file.Content | |
} | |
tests := []struct { | |
name string | |
args args | |
want []string | |
wantErr bool | |
}{ | |
{ | |
name: "both present and equal", | |
args: args{ | |
dumpConfig: dump.Config{SelectorTags: []string{"foo"}}, | |
fileContent: file.Content{Info: &file.Info{SelectorTags: []string{"foo"}}}, | |
}, | |
want: []string{"foo"}, | |
wantErr: false, | |
}, | |
{ | |
name: "both present and equal order invariant", | |
args: args{ | |
dumpConfig: dump.Config{SelectorTags: []string{"foo", "bar"}}, | |
fileContent: file.Content{Info: &file.Info{SelectorTags: []string{"bar", "foo"}}}, | |
}, | |
want: []string{"bar", "foo"}, | |
wantErr: false, | |
}, | |
{ | |
name: "both present and not equal", | |
args: args{ | |
dumpConfig: dump.Config{SelectorTags: []string{"bar"}}, | |
fileContent: file.Content{Info: &file.Info{SelectorTags: []string{"foo"}}}, | |
}, | |
want: nil, | |
wantErr: true, | |
}, | |
{ | |
name: "only file has tags", | |
args: args{ | |
dumpConfig: dump.Config{}, | |
fileContent: file.Content{Info: &file.Info{SelectorTags: []string{"foo"}}}, | |
}, | |
want: []string{"foo"}, | |
wantErr: false, | |
}, | |
{ | |
name: "only config has tags", | |
args: args{ | |
dumpConfig: dump.Config{SelectorTags: []string{"foo"}}, | |
fileContent: file.Content{Info: &file.Info{}}, | |
}, | |
want: []string{"foo"}, | |
wantErr: false, | |
}, | |
} |
Done: 32071ed |
rainest
approved these changes
Jan 26, 2022
AntoineJac
pushed a commit
that referenced
this pull request
Jan 23, 2024
* fix: unexpected error with --select-tag and multiple files When running sync with multiple files and --select-tag, deck simply appends the existing _info.select_tags of the various files. If the same tag(s) are present in the files, these are appended together and making deck fail because tags passed via the command flag and the ones coming from the files are expected to match, but the way files are merged may cause duplicates, hence the unexpected failure. This removes duplicates from the _info.select_tags resulted from the merged files.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When running sync with multiple files and
--select-tag
,deck simply appends the existing
_info.select_tags
of thevarious files. If the same tag(s) are present in the files,
these are appended together making
deck
fail because thetags passed via the command flag and the ones coming from
the files are expected to match, but the way files are
merged may cause duplicates, hence the unexpected failure.
This removes duplicates from the _info.select_tags resulted
from the merged files.
Related to #561