@@ -10,6 +10,16 @@ func TestFindNextArg(t *testing.T) {
1010 {"-X" , "GET" , "arg1" , "--foo" , "bar" },
1111 {"-X" , "GET" , "--server-idea" , "foo" , "/api/arg2" },
1212 {"-XGET" , "--foo" , "bar" , "--foo-bar" , "meow" , "arg3" },
13+ {"-o" , "helm.tar.gz" , "-L" , "-vvv" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
14+ {"-o" , "helm.tar.gz" , "-vvv" , "-L" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
15+ {"-o" , "helm.tar.gz" , "-L" , "-s" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
16+ {"-L" , "-o" , "helm.tar.gz" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
17+ {"-o" , "helm.tar.gz" , "-L" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
18+ {"-L" , "-vvv" , "-o" , "helm.tar.gz" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
19+ {"-L" , "-o" , "helm.tar.gz" , "-vvv" , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
20+ {"-vvv" , "-s" , "-L" , "api/test" },
21+ {"-LsS" , "api/test2" },
22+ {"-ofile.txt" , "-L" , "api/test3" },
1323 }
1424
1525 expected := []struct {
@@ -19,6 +29,24 @@ func TestFindNextArg(t *testing.T) {
1929 {2 , "arg1" },
2030 {4 , "/api/arg2" },
2131 {5 , "arg3" },
32+ {4 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
33+ {4 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
34+ {4 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
35+ {3 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
36+ {3 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
37+ {4 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
38+ {4 , "helm-sh/helm-v3.19.0-linux-amd64.tar.gz" },
39+ {3 , "api/test" },
40+ {1 , "api/test2" },
41+ {2 , "api/test3" },
42+ {- 1 , "" },
43+ {4 , "api/endpoint" },
44+ {0 , "api/endpoint" },
45+ {2 , "api/endpoint" },
46+ {2 , "api/endpoint" },
47+ {- 1 , "" },
48+ {- 1 , "" },
49+ {- 1 , "" },
2250 }
2351
2452 for index , test := range args {
@@ -68,15 +96,15 @@ func TestBuildCommandUrl(t *testing.T) {
6896 uriValue string
6997 expectErr bool
7098 }{
71- {"test1" , []string {"-X" , "GET" , "/api/build/test1" , "--server-id" , "test1" , "--foo" , "bar" }, 2 , "http ://artifactory:8081/artifactory/api/build/test1" , false },
72- {"test2" , []string {"-X" , "GET" , "/api/build/test2" , "--server-idea" , "foo" , "--server-id=test2" }, 2 , "http ://artifactory:8081/artifactory/api/build/test2" , false },
73- {"test3" , []string {"-XGET" , "--/api/build/test3" , "--server-id=" }, 1 , "http ://artifactory:8081/artifactory/api/build/test3" , true },
74- {"test4" , []string {"-XGET" , "-Test4" , "--server-id" , "bar" }, 1 , "http ://artifactory:8081/artifactory/api/build/test4 " , true },
75- {"test5" , []string {"-X" , "GET" , "api/build/test5" , "--server-id" , "test5" , "--foo" , "bar" }, 2 , "http ://artifactory:8081/artifactory/api/build/test5" , false },
99+ {"test1" , []string {"-X" , "GET" , "/api/build/test1" , "--server-id" , "test1" , "--foo" , "bar" }, 2 , "https ://artifactory:8081/artifactory/api/build/test1" , false },
100+ {"test2" , []string {"-X" , "GET" , "/api/build/test2" , "--server-idea" , "foo" , "--server-id=test2" }, 2 , "https ://artifactory:8081/artifactory/api/build/test2" , false },
101+ {"test3" , []string {"-XGET" , "--/api/build/test3" , "--server-id=" }, 1 , "https ://artifactory:8081/artifactory/api/build/test3" , true },
102+ {"test4" , []string {"-XGET" , "-Test4" , "--server-id" , "bar" }, 3 , "https ://artifactory:8081/artifactory/bar " , false },
103+ {"test5" , []string {"-X" , "GET" , "api/build/test5" , "--server-id" , "test5" , "--foo" , "bar" }, 2 , "https ://artifactory:8081/artifactory/api/build/test5" , false },
76104 }
77105
78106 command := & CurlCommand {}
79- urlPrefix := "http ://artifactory:8081/artifactory/"
107+ urlPrefix := "https ://artifactory:8081/artifactory/"
80108 for _ , test := range tests {
81109 command .arguments = test .arguments
82110 t .Run (test .name , func (t * testing.T ) {
0 commit comments