(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func TestMethod_Error(t *testing.T) { |
| 135 | k := New("testkite", "0.0.1") |
| 136 | k.Config.DisableAuthentication = true |
| 137 | k.Config.Port = 9999 |
| 138 | |
| 139 | var testError = errors.New("an error") |
| 140 | |
| 141 | k.PreHandleFunc(func(r *Request) (interface{}, error) { return nil, testError }) |
| 142 | |
| 143 | // the following shouldn't do anything because the previous error breaks the chain |
| 144 | k.HandleFunc("foo", func(r *Request) (interface{}, error) { |
| 145 | return "handle", nil |
| 146 | }) |
| 147 | |
| 148 | k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post1", nil }) |
| 149 | k.PostHandleFunc(func(r *Request) (interface{}, error) { return "post2", nil }) |
| 150 | |
| 151 | go k.Run() |
| 152 | defer k.Close() |
| 153 | <-k.ServerReadyNotify() |
| 154 | |
| 155 | c := New("exp", "0.0.1").NewClient("http://127.0.0.1:9999/kite") |
| 156 | if err := c.Dial(); err != nil { |
| 157 | t.Fatal(err) |
| 158 | } |
| 159 | |
| 160 | _, err := c.TellWithTimeout("foo", 4*time.Second) |
| 161 | if err == nil { |
| 162 | t.Fatal("PreHandle returns an error, however error is non-nil.") |
| 163 | } |
| 164 | |
| 165 | if !strings.HasPrefix(err.Error(), testError.Error()) { |
| 166 | t.Errorf("Error should be '%v', got '%v'", testError, err) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func TestMethod_Base(t *testing.T) { |
| 171 | k := New("testkite", "0.0.1") |
nothing calls this directly
no test coverage detected