forked from diffbot/diffbot-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
95 lines (87 loc) · 1.94 KB
/
options_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package diffbot
import (
"testing"
"time"
)
func TestOptions(t *testing.T) {
for i, v := range testOptionsList {
if s := v.opt.MethodParamString(v.method); s != v.str {
t.Fatalf("%d: expect = %q, got = %q", i, v.str, s)
}
}
}
var testOptionsList = []struct {
method string
opt Options
str string
}{
// empty
{
method: "",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
},
str: "",
},
// case "article", "image", "product":
{
method: "article",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
},
str: "&fields=meta,querystring,images(*)&timeout=5000&callback=abc",
},
{
method: "image",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
},
str: "&fields=meta,querystring,images(*)&timeout=5000&callback=abc",
},
{
method: "product",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
},
str: "&fields=meta,querystring,images(*)&timeout=5000&callback=abc",
},
// case "frontpage":
{
method: "frontpage",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
FrontpageAll: "*",
},
str: "&timeout=5000&all=*",
},
// case "analyze":
{
method: "analyze",
opt: Options{
Fields: "meta,querystring,images(*)",
Timeout: time.Second * 5,
Callback: "abc",
FrontpageAll: "*",
ClassifierMode: "frontpage",
ClassifierStats: "abc",
},
str: "&mode=frontpage&fields=meta,querystring,images(*)&stats=abc",
},
// case "bulk":
// case "crawl":
// case "batch":
// default: // Custom APIs
}