Debian Codegraph @

test/verbose_test.go

raw
1 // Copyright 2012-2018 The NATS Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package test
15
16 import (
17 "testing"
18 )
19
20 func TestVerbosePing(t *testing.T) {
21 s := runProtoServer()
22 defer s.Shutdown()
23
24 c := createClientConn(t, "127.0.0.1", PROTO_TEST_PORT)
25 defer c.Close()
26
27 doConnect(t, c, true, false, false)
28
29 send := sendCommand(t, c)
30 expect := expectCommand(t, c)
31
32 expect(okRe)
33
34 // Ping should still be same
35 send("PING\r\n")
36 expect(pongRe)
37 }
38
39 func TestVerboseConnect(t *testing.T) {
40 s := runProtoServer()
41 defer s.Shutdown()
42
43 c := createClientConn(t, "127.0.0.1", PROTO_TEST_PORT)
44 defer c.Close()
45
46 doConnect(t, c, true, false, false)
47
48 send := sendCommand(t, c)
49 expect := expectCommand(t, c)
50
51 expect(okRe)
52
53 // Connect
54 send("CONNECT {\"verbose\":true,\"pedantic\":true,\"tls_required\":false}\r\n")
55 expect(okRe)
56 }
57
58 func TestVerbosePubSub(t *testing.T) {
59 s := runProtoServer()
60 defer s.Shutdown()
61
62 c := createClientConn(t, "127.0.0.1", PROTO_TEST_PORT)
63 defer c.Close()
64
65 doConnect(t, c, true, false, false)
66 send := sendCommand(t, c)
67 expect := expectCommand(t, c)
68
69 expect(okRe)
70
71 // Pub
72 send("PUB foo 2\r\nok\r\n")
73 expect(okRe)
74
75 // Sub
76 send("SUB foo 1\r\n")
77 expect(okRe)
78
79 // UnSub
80 send("UNSUB 1\r\n")
81 expect(okRe)
82 }