(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func 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 | |
| 95 | func TestMethod_First(t *testing.T) { |
| 96 | k := New("testkite", "0.0.1") |
nothing calls this directly
no test coverage detected