-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator_test.go
70 lines (67 loc) · 1.42 KB
/
generator_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
package serendip
import (
"fmt"
"testing"
)
func TestGenerateRandomArticleMessage(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
{
name: "standard",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GenerateRandomArticleMessage()
if (err != nil) != tt.wantErr {
t.Errorf("GenerateRandomArticleMessage() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != "" {
fmt.Println(got)
} else {
t.Errorf("The got value is empty")
return
}
})
}
}
func TestGenerateSearchResultMessage(t *testing.T) {
type args struct {
query string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "standard",
args: args{"Wikipedia"},
want: `**Wikipedia**
<https://ja.wikipedia.org/wiki/Wikipedia>
**Wikipedia Zero**
<https://ja.wikipedia.org/wiki/Wikipedia%20Zero>
**Wikipedia日本語版**
<https://ja.wikipedia.org/wiki/Wikipedia%E6%97%A5%E6%9C%AC%E8%AA%9E%E7%89%88>
`,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GenerateSearchResultMessage(tt.args.query)
if (err != nil) != tt.wantErr {
t.Errorf("GenerateSearchResultMessage() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("GenerateSearchResultMessage() = %v, want %v", got, tt.want)
}
})
}
}