-
Notifications
You must be signed in to change notification settings - Fork 16
/
connect_test.go
53 lines (44 loc) · 1.11 KB
/
connect_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package memphis
import (
"testing"
)
func TestConnect(t *testing.T) {
c, err := Connect("localhost", "root", ConnectionToken("memphis"))
if err != nil {
t.Error()
return
}
c.Close()
}
func TestNormalizeHost(t *testing.T) {
if "www.google.com" != normalizeHost("http://www.google.com") {
t.Error()
}
if "www.yahoo.com" != normalizeHost("https://www.yahoo.com") {
t.Error()
}
if "http.http.http://" != normalizeHost("http://http.http.http://") {
t.Error()
}
}
func TestProduceNoProducer(t *testing.T) {
c, err := Connect("localhost", "root", ConnectionToken("memphis"))
if err != nil {
t.Error(err)
}
defer c.Close()
err = c.Produce("station_name_c_produce", "producer_name_a", []byte("Hey There!"), nil, nil)
if err != nil {
t.Error(err)
}
err = c.Produce("station_name_c_produce", "producer_name_a", []byte("Hey! Test 2 pleaseee"), nil, nil)
if err != nil {
t.Error(err)
}
pm := c.getProducersMap()
pm.unsetStationProducers("station_name_c_produce")
p := pm.getProducer("producer_name_a")
if p != nil {
t.Error("unsetStationProducers failed to remove key [station_name_c_produce]")
}
}