-
Notifications
You must be signed in to change notification settings - Fork 0
/
nxlog_writer_test.go
84 lines (67 loc) · 2.25 KB
/
nxlog_writer_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package nxlog
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Nxlog writer connector", func() {
Context("with TCP connections", func() {
It("connects successfully to a listening tcp endpoint", func() {
_, err := NewWriter("tcp", "127.0.0.1:3000", nil)
Expect(err).To(BeNil())
})
It("shows an error if connecting to an invalid TCP endpoint", func() {
_, err := NewWriter("tcp", "127.0.0.1:0", nil)
Expect(err).ToNot(BeNil())
})
It("sends properly the data via TCP", func() {
data := "test input tcp"
writer, _ := NewWriter("tcp", "127.0.0.1:3000", nil)
writer.Write([]byte(data), true)
Eventually(tcpResult).Should(Receive(&data))
})
})
Context("with UDP connections", func() {
It("connects successfully to a listening UDP endpoint", func() {
_, err := NewWriter("udp", "127.0.0.1:3001", nil)
Expect(err).To(BeNil())
})
It("sends properly the data via UDP", func() {
data := "test input udp"
writer, _ := NewWriter("udp", "127.0.0.1:3001", nil)
writer.Write([]byte(data), true)
Eventually(udpResult).Should(Receive(&data))
})
})
Context("with SSL connections", func() {
It("connects successfully to a listening SSL endpoint", func() {
_, err := NewWriter("ssl", "127.0.0.1:3002", nil)
Expect(err).To(BeNil())
})
It("shows an error if connecting to an invalid SSL endpoint", func() {
_, err := NewWriter("ssl", "127.0.0.1:0", nil)
Expect(err).ToNot(BeNil())
})
It("sends properly the data via SSL", func() {
data := "test input tls"
writer, _ := NewWriter("ssl", "127.0.0.1:3002", nil)
writer.Write([]byte(data), true)
Eventually(tlsResult).Should(Receive(&data))
})
})
Context("with UDS connections", func() {
It("connects successfully to a listening UDS endpoint", func() {
_, err := NewWriter("unixgram", udsSocket, nil)
Expect(err).To(BeNil())
})
It("shows an error if connecting to an invalid UDS endpoint", func() {
_, err := NewWriter("unixgram", "/tmp/fake", nil)
Expect(err).ToNot(BeNil())
})
It("sends properly the data via UDS", func() {
data := "test input uds"
writer, _ := NewWriter("unixgram", udsSocket, nil)
writer.Write([]byte(data), true)
Eventually(udsResult).Should(Receive(&data))
})
})
})