-
Notifications
You must be signed in to change notification settings - Fork 10
/
http_test.go
64 lines (59 loc) · 1.45 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
59
60
61
62
63
64
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,
"",
"",
"",
0,
})
HTTPStatus := SendRequest(BulkToSend)
if HTTPStatus != 200 {
t.Error("Logs bulk sending failed!")
}
}
func TestSendRequestPostFail(t *testing.T) {
// TODO: update SendRequest for better error handling, and redo this test
t.Skip("Skipping test, the SendRequest can and will only return 0, therefore this test is invalid")
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) {
// TODO: update SendRequest for better error handling, and redo this test
t.Skip("Skipping test, the SendRequest can and will only return 0, therefore this test is invalid")
BulkToSend := CreateBulk()
BulkToSend.AddRecord(Log{
1,
Level.DEBUG,
"Test message",
LogCategory,
"",
"",
"",
0,
})
HTTPStatus := SendRequest(BulkToSend)
if HTTPStatus == 0 {
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!")
}
}