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

Function TestKite_MultipleDial

bug_test.go:12–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestKite_MultipleDial(t *testing.T) {
13 esrv := kite.New("echo-server", "0.0.0")
14 esrv.Config.DisableAuthentication = true
15 if err := esrv.Config.ReadEnvironmentVariables(); err != nil {
16 t.Fatal(err)
17 }
18
19 esrv.HandleFunc("echo", func(r *kite.Request) (interface{}, error) {
20 var arg string
21
22 if err := r.Args.One().Unmarshal(&arg); err != nil {
23 return nil, err
24 }
25
26 if arg == "" {
27 return nil, errors.New("arg is empty")
28 }
29
30 return arg, nil
31 })
32
33 ts := httptest.NewServer(esrv)
34 ecli := kite.New("echo-client", "0.0.0")
35 if err := ecli.Config.ReadEnvironmentVariables(); err != nil {
36 t.Fatal(err)
37 }
38
39 esrv.SetLogLevel(kite.DEBUG)
40 ecli.SetLogLevel(kite.DEBUG)
41
42 c := ecli.NewClient(fmt.Sprintf("%s/kite", ts.URL))
43
44 if err := c.Dial(); err != nil {
45 t.Fatalf("dialing echo-server kite error: %s", err)
46 }
47
48 if err := c.Dial(); err != nil {
49 t.Fatalf("dialing echo-server kite error: %s", err)
50 }
51
52 resp, err := c.Tell("echo", "Hello world!")
53 if err != nil {
54 t.Fatalf("Tell()=%s", err)
55 }
56
57 var reply string
58
59 if err := resp.Unmarshal(&reply); err != nil {
60 t.Fatalf("Unmarshal()=%s", err)
61 }
62
63 if reply != "Hello world!" {
64 t.Fatalf(`got %q, want "Hello world!"`, reply)
65 }
66}

Callers

nothing calls this directly

Calls 8

DialMethod · 0.95
TellMethod · 0.95
FatalMethod · 0.80
HandleFuncMethod · 0.80
UnmarshalMethod · 0.80
OneMethod · 0.80
NewClientMethod · 0.80

Tested by

no test coverage detected