-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
159 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dataflow | ||
|
||
import ( | ||
"github.com/guonaihong/gout/setting" | ||
) | ||
|
||
// 存放全局配置选项 | ||
var GlobalSetting setting.Setting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package gout | ||
|
||
import ( | ||
"bytes" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/guonaihong/gout/dataflow" | ||
) | ||
|
||
func TestQuery_NotIgnoreEmpty(t *testing.T) { | ||
|
||
total := int32(0) | ||
router := setupMethod(&total) | ||
|
||
ts := httptest.NewServer(http.HandlerFunc(router.ServeHTTP)) | ||
defer ts.Close() | ||
|
||
query := H{ | ||
"t": 1296, | ||
"callback": "searchresult", | ||
"q": "美食", | ||
"stype": 1, | ||
"pagesize": 100, | ||
"pagenum": 1, | ||
"imageType": 2, | ||
"imageColor": "", | ||
"brand": "", | ||
"imageSType": "", | ||
"fr": 1, | ||
"sortFlag": 1, | ||
"imageUType": "", | ||
"btype": "", | ||
"authid": "", | ||
"_": int64(1611822443760), | ||
} | ||
|
||
var out bytes.Buffer | ||
SaveDebug := func() dataflow.DebugOpt { | ||
return DebugFunc(func(o *DebugOption) { | ||
o.Write = &out | ||
o.Debug = true | ||
}) | ||
} | ||
|
||
// 默认忽略空值 | ||
err := GET(ts.URL).Debug(SaveDebug()).SetQuery(query).Do() | ||
assert.NoError(t, err) | ||
// 没有authid字段 | ||
assert.Equal(t, bytes.Index(out.Bytes(), []byte("authid")), -1) | ||
|
||
// 重置bytes.Buffer | ||
out.Reset() | ||
NotIgnoreEmpty() | ||
|
||
err = GET(ts.URL).Debug(SaveDebug()).SetQuery(query).Do() | ||
assert.NoError(t, err) | ||
// 有authid字段 | ||
assert.NotEqual(t, bytes.Index(out.Bytes(), []byte("authid")), -1) | ||
|
||
IgnoreEmpty() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package setting | ||
|
||
// 设置 | ||
type Setting struct { | ||
NotIgnoreEmpty bool //控制是否使用空值 | ||
|
||
NoAutoContentType bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package gout | ||
|
||
// Version show version | ||
const Version = "v0.1.4" | ||
const Version = "v0.1.5" |