forked from linkpoolio/bridges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
executable file
·44 lines (38 loc) · 949 Bytes
/
main_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
package main
import (
"github.com/linkpoolio/bridges"
"github.com/stretchr/testify/assert"
"testing"
)
func TestWolframAlpha_Run(t *testing.T) {
cases := []struct {
name string
data map[string]interface{}
error string
}{
{"Invalid Index", map[string]interface{}{
"index": 1,
"query": "How far is Los Angeles from New York?",
}, "Invalid index"},
{"Unauthorised", map[string]interface{}{
"index": 0,
"query": "How far is Los Angeles from New York?",
}, "Unexpected api status code: 403"},
}
wa := WolframAlpha{}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
json, err := bridges.ParseInterface(c.data)
assert.Nil(t, err)
h := bridges.NewHelper(json)
_, err = wa.Run(h)
assert.Equal(t, c.error, err.Error())
})
}
}
func TestWolframAlpha_Opts(t *testing.T) {
cc := WolframAlpha{}
opts := cc.Opts()
assert.Equal(t, opts.Name, "WolframAlpha")
assert.True(t, opts.Lambda)
}