-
Notifications
You must be signed in to change notification settings - Fork 10
/
bulk_test.go
54 lines (45 loc) · 1.05 KB
/
bulk_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
package coralogix
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewBulk(t *testing.T) {
assert.IsType(t, &Bulk{}, CreateBulk(), "Bulk creation failed!")
}
func TestBulk_AddRecord(t *testing.T) {
RecordsBulk := CreateBulk()
RecordsBulk.AddRecord(Log{
float64(time.Now().Unix()) * 1000.0,
Level.DEBUG,
"Test message",
LogCategory,
"",
"",
"",
0,
})
assert.True(t, len(RecordsBulk.LogEntries) >= 1, "Adding new record to bulk failed!")
}
func TestBulk_ToJSON(t *testing.T) {
RecordsBulkJSON := CreateBulk().ToJSON()
assert.NotNil(t, RecordsBulkJSON)
assert.IsType(t, []byte(""), RecordsBulkJSON, "Error while converting bulk to JSON!")
}
func TestBulk_ToJSONFail(t *testing.T) {
RecordsBulk := CreateBulk()
RecordsBulk.AddRecord(*InvalidLogMessage())
assert.Nil(t, RecordsBulk.ToJSON(), "Error while catching JSON converting error!")
}
func CreateBulk() *Bulk {
return NewBulk(
Credentials{
GetEnv(
"PRIVATE_KEY",
"7569303a-6269-4d2c-bf14-1aec9b1786a4",
),
"sdk-go",
"test",
},
)
}