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

Function TestMethod_First

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

Source from the content-addressed store, hash-verified

93}
94
95func TestMethod_First(t *testing.T) {
96 k := New("testkite", "0.0.1")
97
98 k.Config.DisableAuthentication = true
99 k.Config.Port = 9998
100
101 k.MethodHandling = ReturnFirst
102
103 k.PreHandleFunc(func(r *Request) (interface{}, error) { return nil, nil })
104 k.PreHandleFunc(func(r *Request) (interface{}, error) { return "hello", nil })
105
106 // the following shouldn't do anything because the previous error breaks the chain
107 k.HandleFunc("foo", func(r *Request) (interface{}, error) {
108 return "handle", nil
109 })
110
111 k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post1", nil })
112 k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post2", nil })
113
114 go k.Run()
115 defer k.Close()
116 <-k.ServerReadyNotify()
117
118 c := New("exp", "0.0.1").NewClient("http://127.0.0.1:9998/kite")
119 if err := c.Dial(); err != nil {
120 t.Fatal(err)
121 }
122
123 result, err := c.TellWithTimeout("foo", 4*time.Second)
124 if err != nil {
125 t.Fatal(err)
126 }
127
128 if result.MustString() != "hello" {
129 t.Errorf("Latest response should be hello, got %s", result.MustString())
130 }
131
132}
133
134func TestMethod_Error(t *testing.T) {
135 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