@@ -9,83 +9,107 @@ func TestHttpie2Curl(t *testing.T) {
99 }{
1010 {
1111 []string {"http" , ":/foo" },
12- `curl ' localhost/foo' ` ,
12+ `curl localhost/foo` ,
1313 },
1414 {
1515 []string {"http" , ":3000/bar" },
16- `curl ' localhost:3000/bar' ` ,
16+ `curl localhost:3000/bar` ,
1717 },
1818 {
1919 []string {"http" , ":" },
20- `curl ' localhost/' ` ,
20+ `curl localhost/` ,
2121 },
2222 {
2323 []string {"http" , "example.org" , "id==1" },
24- `curl ' example.org?id=1' ` ,
24+ `curl example.org?id=1` ,
2525 },
2626 {
2727 []string {"http" , "--auth" , "username" , "example.org" , "id==1" },
28- `curl --user ' username' ' example.org?id=1' ` ,
28+ `curl --user username example.org?id=1` ,
2929 },
3030 {
3131 []string {"http" , "--auth" , "username" , "example.org" , "id==1" , "foo:bar" },
32- `curl --user ' username' --header 'foo: bar' ' example.org?id=1' ` ,
32+ `curl --user username --header 'foo: bar' example.org?id=1` ,
3333 },
3434 {
3535 []string {"http" , "--form" , "--auth" , "username" , "example.org" , "id==1" , "foo:bar" , "foo=bar" },
36- `curl --user ' username' --header 'foo: bar' --data ' foo=bar' ' example.org?id=1' ` ,
36+ `curl --user username --header 'foo: bar' --data foo=bar example.org?id=1` ,
3737 },
3838 {
3939 []string {"http" , "--auth" , "username" , "example.org" , "id==1" , "foo:bar" , "foo=bar" },
40- `curl --user ' username' --header 'foo: bar' --header 'Content-Type: application/json' --data '{"foo":"bar"}' ' example.org?id=1' ` ,
40+ `curl --user username --header 'foo: bar' --header 'Content-Type: application/json' --data '{"foo":"bar"}' example.org?id=1` ,
4141 },
4242 {
4343 []string {"http" , "-f" , "--auth" , "username" , "example.org" , "id==1" , "foo:bar" , "foo=bar" , "file@test_obj.json" },
44- `curl --user ' username' --header 'foo: bar' --form 'file=@"test_obj.json"' --data ' foo=bar' ' example.org?id=1' ` ,
44+ `curl --user username --header 'foo: bar' --form 'file=@"test_obj.json"' --data foo=bar example.org?id=1` ,
4545 },
4646 {
4747 []string {"http" , "--auth" , "username" , "example.org" , "id==1" , "foo:bar" , "foo=bar" , `a:={"foo": "bar"}` },
48- `curl --user ' username' --header 'foo: bar' --header 'Content-Type: application/json' --data '{"a":{"foo":"bar"},"foo":"bar"}' ' example.org?id=1' ` ,
48+ `curl --user username --header 'foo: bar' --header 'Content-Type: application/json' --data '{"a":{"foo":"bar"},"foo":"bar"}' example.org?id=1` ,
4949 },
5050 {
5151 []string {"http" , "--auth" , "username" , "POST" , "example.org" , "id==1" , "foo:bar" , "foo=bar" , `a:={"foo": "bar"}` },
52- `curl --request ' POST' --user ' username' --header 'foo: bar' --header 'Content-Type: application/json' --data '{"a":{"foo":"bar"},"foo":"bar"}' ' example.org?id=1' ` ,
52+ `curl --request POST --user username --header 'foo: bar' --header 'Content-Type: application/json' --data '{"a":{"foo":"bar"},"foo":"bar"}' example.org?id=1` ,
5353 },
5454 {
5555 []string {"http" , "PUT" , "z.cn" },
56- `curl --request ' PUT' ' z.cn' ` ,
56+ `curl --request PUT z.cn` ,
5757 },
5858 {
5959 []string {"http" , "z.cn" },
60- "curl ' z.cn' " ,
60+ "curl z.cn" ,
6161 },
6262 {
6363 []string {"http" , "--auth" , "username" , "--auth-type" , "basic" , "example.org" , "id==1" },
64- `curl --user ' username' --basic ' example.org?id=1' ` ,
64+ `curl --user username --basic example.org?id=1` ,
6565 },
6666 {
6767 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "example.org" , "id==1" },
68- `curl --user ' username' --digest ' example.org?id=1' ` ,
68+ `curl --user username --digest example.org?id=1` ,
6969 },
7070 {
7171 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "example.org" , "id==1" },
72- `curl --user ' username' --digest --proxy ' http:http://foo.bar:3128' ' example.org?id=1' ` ,
72+ `curl --user username --digest --proxy http:http://foo.bar:3128 example.org?id=1` ,
7373 },
7474 {
7575 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "example.org" , "id==1" },
76- `curl --user ' username' --digest --proxy ' http:http://foo.bar:3128' ' example.org?id=1' ` ,
76+ `curl --user username --digest --proxy http:http://foo.bar:3128 example.org?id=1` ,
7777 },
7878 {
7979 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "--follow" , "example.org" , "id==1" },
80- `curl --user ' username' --digest --proxy ' http:http://foo.bar:3128' --location ' example.org?id=1' ` ,
80+ `curl --user username --digest --proxy http:http://foo.bar:3128 --location example.org?id=1` ,
8181 },
8282 {
8383 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "--follow" , "--max-redirects" , "10" , "example.org" , "id==1" },
84- `curl --user ' username' --digest --proxy ' http:http://foo.bar:3128' --location --max-redirs '10' ' example.org?id=1' ` ,
84+ `curl --user username --digest --proxy http:http://foo.bar:3128 --location --max-redirs 10 example.org?id=1` ,
8585 },
8686 {
8787 []string {"http" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "--follow" , "--max-redirects" , "10" , "--timeout" , "30" , "example.org" , "id==1" },
88- `curl --user 'username' --digest --proxy 'http:http://foo.bar:3128' --location --max-redirs '10' --max-time '30' 'example.org?id=1'` ,
88+ `curl --user username --digest --proxy http:http://foo.bar:3128 --location --max-redirs 10 --max-time 30 example.org?id=1` ,
89+ },
90+ {
91+ []string {"https" , "--auth" , "username" , "--auth-type" , "digest" , "--proxy" , "http:http://foo.bar:3128" , "--follow" , "--max-redirects" , "10" , "--timeout" , "30" , "example.org" , "id==1" },
92+ `curl --user username --digest --proxy http:http://foo.bar:3128 --location --max-redirs 10 --max-time 30 https://example.org?id=1` ,
93+ },
94+ {
95+ []string {"https" , "pie.dev" },
96+ `curl https://pie.dev` ,
97+ },
98+ {
99+ []string {"http" , "pie.dev" },
100+ `curl pie.dev` ,
101+ },
102+ {
103+ []string {"https" , "pie.dev" , "key==mykey" , "secret==mysecret" },
104+ `curl 'https://pie.dev?key=mykey&secret=mysecret'` ,
105+ },
106+ {
107+ []string {"http" , "-a" , "username:password" , "pie.dev" },
108+ `curl --user username:password pie.dev` ,
109+ },
110+ {
111+ []string {"http" , "pie.dev" , "-a" , "username:password" },
112+ `curl --user username:password pie.dev` ,
89113 },
90114 }
91115
@@ -94,13 +118,13 @@ func TestHttpie2Curl(t *testing.T) {
94118 // want string
95119 // }{
96120 // {
97- // []string{"http", "--auth", "username", "example.org ", "id==1 ", "foo:bar", "foo=bar", `a:={"foo": "bar"}` },
98- // `curl --user ' username' --header 'foo: bar' --header 'Content-Type: application/json' --data '{"a":{"foo":"bar"},"foo":"bar"}' 'example.org?id=1' `,
121+ // []string{"http", "pie.dev ", "-a ", "username:password" },
122+ // `curl --user username:password pie.dev `,
99123 // },
100124 // }
101125
102126 for _ , c := range cases {
103- gotStringer , warningMessages , err := Httpie2Curl (c .in [ 1 :] )
127+ gotStringer , warningMessages , err := Httpie2Curl (c .in )
104128 if len (warningMessages ) > 0 {
105129 t .Logf ("Httpie2Curl warning messages: %#v in: %#v" , warningMessages , c .in )
106130 }
0 commit comments