]> 127.0.0.1 Git - part/.git/commitdiff
90 v0.1.8
authorqydysky <qydysky@foxmail.com>
Sat, 31 Oct 2020 19:26:03 +0000 (03:26 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 31 Oct 2020 19:26:03 +0000 (03:26 +0800)
get/Get.go [moved from Get.go with 93% similarity]
get/Get_test.go [new file with mode: 0644]

similarity index 93%
rename from Get.go
rename to get/Get.go
index 8e328428ee5539fa0c55a9e380022074ee845a1f..3b5ee96e3bf25c5fdddde648160558644fb9ff83 100644 (file)
--- a/Get.go
@@ -3,6 +3,7 @@ package part
 import (
        "strings"
        "errors"
+       p "github.com/qydysky/part"
 )
 
 type get struct {
@@ -12,12 +13,12 @@ type get struct {
        Err error
 }
 
-func Get(r Rval) (o *get){
+func Get(r p.Rval) (o *get){
        o = new(get)
 
        if r.Url == "" {o.Err = errors.New("url == nil");return}
 
-       R := Req()
+       R := p.Req()
        o.Err = R.Reqf(r)
        (*o).body = R.Respon
 
diff --git a/get/Get_test.go b/get/Get_test.go
new file mode 100644 (file)
index 0000000..e1a5a38
--- /dev/null
@@ -0,0 +1,17 @@
+package part
+
+import (
+       "testing"
+       p "github.com/qydysky/part"
+)
+
+func Test_get(t *testing.T) {
+       g := Get(p.Rval{
+               Url:"https://www.baidu.com/",
+       })
+       g.S(`<head><meta http-equiv="`, `"`, 0, 0)
+       if g.Err != nil || g.RS != `Content-Type` {return}
+       g.S(`<head><meta http-equiv="`, `<meta content="`, 0, 0)
+       if g.Err != nil {return}
+       if s,e := SS(g.RS, `content="`, `"`, 0, 0);e != nil || s != `text/html;charset=utf-8` {return}
+}