(t *testing.T)
| 93 | } |
| 94 | |
| 95 | func 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 | |
| 134 | func TestMethod_Error(t *testing.T) { |
| 135 | k := New("testkite", "0.0.1") |
nothing calls this directly
no test coverage detected