From 6c14d25d442a819bf37e228d936e6a2a05de747d Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 3 May 2023 20:56:36 +0200 Subject: [PATCH] tests: TestParseCliOpts: de-uglify testcase list --- cli_args_test.go | 70 +++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/cli_args_test.go b/cli_args_test.go index 74255f2..3220196 100644 --- a/cli_args_test.go +++ b/cli_args_test.go @@ -131,48 +131,46 @@ func TestParseCliOpts(t *testing.T) { o argContainer } - var testcases []testcaseContainer - - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs"}, - o: defaultArgs, - }) + testcases := []testcaseContainer{ + { + i: []string{"gocryptfs"}, + o: defaultArgs, + }, + } o := defaultArgs o.quiet = true - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "-q"}, - o: o, - }) - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "--q"}, - o: o, - }) - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "-quiet"}, - o: o, - }) - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "--quiet"}, - o: o, - }) + testcases = append(testcases, []testcaseContainer{ + { + i: []string{"gocryptfs", "-q"}, + o: o, + }, { + i: []string{"gocryptfs", "--q"}, + o: o, + }, { + i: []string{"gocryptfs", "-quiet"}, + o: o, + }, { + i: []string{"gocryptfs", "--quiet"}, + o: o, + }, + }...) o = defaultArgs o.exclude = []string{"foo", "bar"} - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "-e", "foo", "-e", "bar"}, - o: o, - }) - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "--exclude", "foo", "--exclude", "bar"}, - o: o, - }) - /* TODO BROKEN - testcases = append(testcases, testcaseContainer{ - i: []string{"gocryptfs", "--exclude", "foo", "-e", "bar"}, - o: o, - }) - */ + testcases = append(testcases, []testcaseContainer{ + { + i: []string{"gocryptfs", "-e", "foo", "-e", "bar"}, + o: o, + }, { + i: []string{"gocryptfs", "--exclude", "foo", "--exclude", "bar"}, + o: o, + }, /* TODO BROKEN { + i: []string{"gocryptfs", "--exclude", "foo", "-e", "bar"}, + o: o, + },*/ + }...) + for _, tc := range testcases { o := parseCliOpts(tc.i) if !reflect.DeepEqual(o, tc.o) {