-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_test.go
51 lines (47 loc) · 1.07 KB
/
find_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
package ma_test
import (
"net/http"
"testing"
"github.com/bzimmer/ma"
)
func TestFind(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/!authuser", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "testdata/user_cmac.json")
})
mux.HandleFunc("/album!search", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "testdata/album_search_marmot.json")
})
mux.HandleFunc("/node!search", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "testdata/node_search_marmot.json")
})
for _, tt := range []harness{
{
name: "find",
args: []string{"find", "Marmot"},
counters: map[string]int{
"find.album": 10,
"find.node": 250,
},
},
{
name: "find nodes",
args: []string{"find", "-n", "Marmot"},
counters: map[string]int{
"find.node": 250,
},
},
{
name: "find albums",
args: []string{"find", "-a", "Marmot"},
counters: map[string]int{
"find.album": 10,
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
run(t, &tt, mux, ma.CommandFind)
})
}
}