Skip to content

Commit 6d290fd

Browse files
added-tests-parseArgs-func
1 parent 2dea493 commit 6d290fd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

internal/commands/scan_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,3 +2237,24 @@ func TestCreateScanWith_ScaResolver_Source_as_Zip(t *testing.T) {
22372237
err := execCmdNotNilAssertion(t, baseArgs...)
22382238
assert.Assert(t, strings.Contains(err.Error(), ScaResolverZipNotSupportedErr), err.Error())
22392239
}
2240+
2241+
func Test_parseArgs(t *testing.T) {
2242+
tests := []struct {
2243+
inputString string
2244+
lenOfArgs int
2245+
}{
2246+
{"hitesh", 1},
2247+
{`test test1`, 2},
2248+
{"--gradle-parameters='-Prepository.proxy.url=123 -Prepository.proxy.username=123 -Prepository.proxy.password=123' --log-level Debug", 3},
2249+
}
2250+
2251+
for _, test := range tests {
2252+
fmt.Println("test ::", test)
2253+
result := parseArgs(test.inputString)
2254+
if len(result) != test.lenOfArgs {
2255+
fmt.Println("len:: ", len(result))
2256+
t.Errorf(" test case failed for params %v", test)
2257+
}
2258+
}
2259+
2260+
}

0 commit comments

Comments
 (0)