forked from davemachado/public-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_test.go
More file actions
50 lines (47 loc) · 1.26 KB
/
Copy pathutil_test.go
File metadata and controls
50 lines (47 loc) · 1.26 KB
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
package main
import "testing"
func TestGetCategories(t *testing.T) {
actual := parseCategories([]Entry{
Entry{Category: "A"},
Entry{Category: "B"},
Entry{Category: "B"},
Entry{Category: "C"},
Entry{Category: "D"},
})
expected := []string{"A", "B", "C", "D"}
if len(actual) != len(expected) {
t.Fatalf("bad parsing: expected %v, got %v", expected, actual)
}
for i := 0; i < len(expected); i++ {
if actual[i] != expected[i] {
t.Errorf("bad element: expected %q, got %q", actual[i], expected[i])
}
}
}
func TestCheckEntryMatches(t *testing.T) {
entry := Entry{
API: "examplesAsAService",
Description: "provide classic examples of classic things",
Auth: "apiKey",
HTTPS: true,
Cors: "Unknown",
Link: "http://www.example.com",
Category: "Development",
}
search := &SearchRequest{}
if !checkEntryMatches(entry, search) {
t.Errorf("failed to match entry and search")
}
search.HTTPS = "true"
if !checkEntryMatches(entry, search) {
t.Errorf("failed to match entry and search")
}
search.Auth = "OAuth"
if checkEntryMatches(entry, search) {
t.Errorf("failed to match entry and search")
}
search.Cors = "unknown"
if checkEntryMatches(entry, search) {
t.Errorf("failed to match entry and search")
}
}