updated tests

This commit is contained in:
Andy Arthur
2020-05-20 16:27:26 -05:00
parent 0940409774
commit 75b1044723
2 changed files with 20 additions and 19 deletions
+6 -6
View File
@@ -12,29 +12,29 @@ teardown() {
@test "dolt supports Nix style argument parsing" {
dolt checkout -b this-should-work
run dolt branch
[ $status -eq 0 ]
[ $status -eq 0 ] || echo $output
[[ "$output" =~ "this-should-work" ]] || false
dolt checkout master
dolt branch -d this-should-work
dolt checkout -b "this-should-work"
run dolt branch
[ $status -eq 0 ]
[ $status -eq 0 ] || echo $output
[[ "$output" =~ "this-should-work" ]] || false
dolt checkout master
dolt branch -d "this-should-work"
dolt checkout --b "this-should-work"
run dolt branch
[ $status -eq 0 ]
[ $status -eq 0 ] || echo $output
[[ "$output" =~ "this-should-work" ]] || false
dolt checkout master
dolt branch --d "this-should-work"
skip "Need spaces after single dash arguments"
dolt checkout -bthis-should-work
run dolt checkout -bthis-should-work
[ $status -eq 0 ] || echo $output
run dolt branch
[ $status -eq 0 ]
[ $status -eq 0 ] || echo $output
[[ "$output" =~ "this-should-work" ]] || false
dolt checkout master
dolt branch -dthis-should-work
+14 -13
View File
@@ -17,6 +17,9 @@ package argparser
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var forceOpt = &Option{"force", "f", "", OptionalFlag, "force desc", nil}
@@ -82,21 +85,19 @@ func TestParsing(t *testing.T) {
}
for _, test := range tests {
parser := NewArgParser()
t.Run(test.name, func(t *testing.T) {
parser := NewArgParser()
for _, opt := range test.options {
parser.SupportOption(opt)
}
res, err := parser.Parse(test.args)
if err != nil {
t.Error("In test", test.name, err)
} else {
if !res.Equals(&ArgParseResults{test.expectedOpts, test.expectedArgs, parser}) {
t.Error("In test", test.name, "result did not match expected")
for _, opt := range test.options {
parser.SupportOption(opt)
}
}
exp := &ArgParseResults{test.expectedOpts, test.expectedArgs, parser}
res, err := parser.Parse(test.args)
require.NoError(t, err)
assert.Equal(t, exp, res)
})
}
}