diff options
author | Paul Okstad <pokstad@gitlab.com> | 2019-09-25 10:37:17 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-09-25 10:37:17 +0300 |
commit | ac096b678698292f0b42772f62ee71646220293e (patch) | |
tree | 07e622ffdc7f31d575e2f8d208df7589f6cb310b /internal/git/safecmd_test.go | |
parent | 2c7becb8d3fd9fc0033f602104183400abd49461 (diff) |
ConfigPair option for DSL
Diffstat (limited to 'internal/git/safecmd_test.go')
-rw-r--r-- | internal/git/safecmd_test.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/internal/git/safecmd_test.go b/internal/git/safecmd_test.go index 1be8fbeb5..4d8689cc5 100644 --- a/internal/git/safecmd_test.go +++ b/internal/git/safecmd_test.go @@ -32,7 +32,11 @@ func TestFlagValidation(t *testing.T) { // valid SubSubCmd inputs {option: git.SubSubCmd{"meow"}, valid: true}, - // valid FlagCombo inputs + // valid ConfigPair inputs + {option: git.ConfigPair{"a.b.c", "d"}, valid: true}, + {option: git.ConfigPair{"core.sound", "meow"}, valid: true}, + {option: git.ConfigPair{"asdf-qwer.1234-5678", ""}, valid: true}, + {option: git.ConfigPair{"http.https://user@example.com/repo.git.user", "kitty"}, valid: true}, // invalid Flag inputs {option: git.Flag{"-*"}}, // invalid character @@ -46,6 +50,15 @@ func TestFlagValidation(t *testing.T) { // invalid SubSubCmd inputs {option: git.SubSubCmd{"--meow"}}, // cannot start with dash + + // invalid ConfigPair inputs + {option: git.ConfigPair{"", ""}}, // key cannot be empty + {option: git.ConfigPair{" ", ""}}, // key cannot be whitespace + {option: git.ConfigPair{"asdf", ""}}, // two components required + {option: git.ConfigPair{"asdf.", ""}}, // 2nd component must be non-empty + {option: git.ConfigPair{"--asdf.asdf", ""}}, // key cannot start with dash + {option: git.ConfigPair{"as[[df.asdf", ""}}, // 1st component cannot contain non-alphanumeric + {option: git.ConfigPair{"asdf.as]]df", ""}}, // 2nd component cannot contain non-alphanumeric } { args, err := tt.option.ValidateArgs() if tt.valid { @@ -160,6 +173,15 @@ func TestSafeCmdValid(t *testing.T) { }, expectArgs: []string{"noun", "verb", "-", "--adjective"}, }, + { + subCmd: git.SubCmd{ + Name: "config", + Flags: []git.Option{ + git.ConfigPair{"user.name", "jramsay"}, + }, + }, + expectArgs: []string{"config", "user.name", "jramsay"}, + }, } { cmd, err := git.SafeCmd(ctx, testRepo, tt.globals, tt.subCmd) require.NoError(t, err) |