forked from coralogix/go-coralogix-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_test.go
58 lines (53 loc) · 1.27 KB
/
http_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
package coralogix
import (
"reflect"
"testing"
"time"
)
func TestSendRequestSuccess(t *testing.T) {
BulkToSend := CreateBulk()
BulkToSend.AddRecord(Log{
float64(time.Now().Unix()) * 1000.0,
Level.DEBUG,
"Test message",
LogCategory,
"",
"",
"",
})
HttpStatus := SendRequest(BulkToSend)
if HttpStatus != 200 {
t.Error("Logs bulk sending failed!")
}
}
func TestSendRequestPostFail(t *testing.T) {
SetDebug(true)
BulkToSend := CreateBulk()
BulkToSend.AddRecord(*InvalidLogMessage())
HttpStatus := SendRequest(BulkToSend)
if HttpStatus > 0 {
t.Error("Sending of invalid request should be failed!")
}
}
func TestSendRequestErrorResponseStatus(t *testing.T) {
BulkToSend := CreateBulk()
BulkToSend.AddRecord(Log{
1,
Level.DEBUG,
"Test message",
LogCategory,
"",
"",
"",
})
HttpStatus := SendRequest(BulkToSend)
if HttpStatus == 200 {
t.Error("Logs bulk was successful!")
}
}
func TestGetTimeSync(t *testing.T) {
Status, TimeDelta := GetTimeSync()
if Status == false || reflect.TypeOf(TimeDelta).Kind() != reflect.Float64 {
t.Error("Time synchronization failed!")
}
}