diff --git a/.drone.yml b/.drone.yml index 50a4612..511f0fc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,9 @@ -workspace: - base: /go - path: src/golang/library -pipeline: - test: +kind: pipeline +type: docker +name: clone + +steps: + - name: test-golang image: golang:1.18 commands: - go env -w GO111MODULE=on diff --git a/.gitignore b/.gitignore index c316f13..114804c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ .idea .vscode *.log -*_test.go gomod.sh /vendor/ diff --git a/http_test.go b/http_test.go new file mode 100644 index 0000000..8842723 --- /dev/null +++ b/http_test.go @@ -0,0 +1,26 @@ +package gorequest + +import ( + "testing" +) + +func TestGet(t *testing.T) { + appHttp := NewHttp() + appHttp.SetDebug() + //appHttp.SetUri("https://api.dtapp.net/ip") + get, err := appHttp.Get("https://api.dtapp.net/ip") + + t.Logf("get:%+v\n", get) + t.Logf("get.ResponseBody:%s\n", get.ResponseBody) + t.Logf("err:%s\n", err) +} + +func TestPost(t *testing.T) { + appHttp := NewHttp() + appHttp.SetUri("https://api.dtapp.net/ip") + get, err := appHttp.Post() + + t.Logf("get:%+v\n", get) + t.Logf("get.ResponseBody:%s\n", get.ResponseBody) + t.Logf("err:%s\n", err) +} diff --git a/params_test.go b/params_test.go new file mode 100644 index 0000000..b620de4 --- /dev/null +++ b/params_test.go @@ -0,0 +1,19 @@ +package gorequest + +import ( + "log" + "testing" +) + +func TestParams(t *testing.T) { + params1 := NewParams() + params2 := NewParams() + params1.Set("a", "1") + params2.Set("b", "2") + params3 := NewParamsWith(params1, params2) + log.Println(params1.DeepCopy()) + log.Println(params2.DeepCopy()) + log.Println(params3.DeepCopy()) + log.Println(params1.DeepCopy()) + log.Println(params2.DeepCopy()) +} diff --git a/url_test.go b/url_test.go new file mode 100644 index 0000000..9760381 --- /dev/null +++ b/url_test.go @@ -0,0 +1,12 @@ +package gorequest + +import "testing" + +func TestUrlParse(t *testing.T) { + t.Logf("%+v", UriParse("https://api.dtapp.net/ip?ip=127.0.0.1#history")) + t.Logf("%+v", UriParse("https://test:abcd123@golangbyexample.com:8000/tutorials/intro?type=advance&compact=false#history")) + t.Logf("%+v", UriFilterExcludeQueryString("/")) + t.Logf("%+v", UriFilterExcludeQueryString("/favicon.ico")) + t.Logf("%+v", UriFilterExcludeQueryString("/ip")) + t.Logf("%+v", UriFilterExcludeQueryString("/ip?ip=127.0.0.1")) +} diff --git a/user_agent_test.go b/user_agent_test.go new file mode 100644 index 0000000..b4ccdbd --- /dev/null +++ b/user_agent_test.go @@ -0,0 +1,15 @@ +package gorequest + +import "testing" + +func TestGetRandomUserAgentSystem(t *testing.T) { + t.Log(GetRandomUserAgentSystem()) +} + +func TestGetRandomUserAgent(t *testing.T) { + t.Log(GetRandomUserAgent()) +} + +func TestDtaUa(t *testing.T) { + t.Log(DtaUa()) +}