-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscovery_test.go
More file actions
48 lines (36 loc) · 785 Bytes
/
Copy pathdiscovery_test.go
File metadata and controls
48 lines (36 loc) · 785 Bytes
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
package discovery
import (
"github.com/Masterminds/cookoo"
"testing"
)
func TestToken(t *testing.T) {
orig := TokenFile
defer func() {
TokenFile = orig
}()
TokenFile = "testdata/secret.txt"
tok, err := Token()
if err != nil {
t.Errorf("Error getting token: %s", err)
}
if string(tok) != "c0ff33" {
t.Errorf("Expected c0ff33, got '%s'", string(tok))
}
}
func TestFoo(t *testing.T) {
orig := TokenFile
defer func() {
TokenFile = orig
}()
TokenFile = "testdata/secret.txt"
reg, router, cxt := cookoo.Cookoo()
reg.Route("test", "Test route").
Does(GetToken, "res")
if err := router.HandleRequest("test", cxt, true); err != nil {
t.Error(err)
}
v := cxt.Get("res", "").(string)
if v != "c0ff33" {
t.Errorf("Expected c0ff33, got '%s'", v)
}
}