MCPcopy Index your code
hub / github.com/koding/kite / TestMethod_Latest

Function TestMethod_Latest

method_test.go:57–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestMethod_Latest(t *testing.T) {
58 k := New("testkite", "0.0.1")
59 k.Config.DisableAuthentication = true
60 k.Config.Port = 9997
61
62 k.MethodHandling = ReturnLatest
63
64 k.PreHandleFunc(func(r *Request) (interface{}, error) { return nil, nil })
65 k.PreHandleFunc(func(r *Request) (interface{}, error) { return "hello", nil })
66
67 // the following shouldn't do anything because the previous error breaks the chain
68 k.HandleFunc("foo", func(r *Request) (interface{}, error) {
69 return "handle", nil
70 })
71
72 k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post1", nil })
73 k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post2", nil })
74
75 go k.Run()
76 defer k.Close()
77 <-k.ServerReadyNotify()
78
79 c := New("exp", "0.0.1").NewClient("http://127.0.0.1:9997/kite")
80 if err := c.Dial(); err != nil {
81 t.Fatal(err)
82 }
83
84 result, err := c.TellWithTimeout("foo", 4*time.Second)
85 if err != nil {
86 t.Fatal(err)
87 }
88
89 if result.MustString() != "post2" {
90 t.Errorf("Latest response should be post2, got %s", result.MustString())
91 }
92
93}
94
95func TestMethod_First(t *testing.T) {
96 k := New("testkite", "0.0.1")

Callers

nothing calls this directly

Calls 12

DialMethod · 0.95
TellWithTimeoutMethod · 0.95
HandleFuncMethod · 0.80
ServerReadyNotifyMethod · 0.80
NewClientMethod · 0.80
FatalMethod · 0.80
MustStringMethod · 0.80
NewFunction · 0.70
PreHandleFuncMethod · 0.45
PostHandleFuncMethod · 0.45
RunMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected