-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper_test.go
47 lines (41 loc) · 1.35 KB
/
helper_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
// © 2016-2024 Graylog, Inc.
package logger
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGoodJson(t *testing.T) {
assert.True(t, parseable("[ ]"))
assert.True(t, parseable("[\n]"))
assert.True(t, parseable("[\n\t\n]"))
assert.True(t, parseable("[\"A\"]")) // check double quotes
assert.True(t, parseable("[\"A\",\"B\"]")) // check double quotes
}
func TestInvalidJson(t *testing.T) {
assert.False(t, parseable("nil"))
assert.False(t, parseable(""))
assert.False(t, parseable(" "))
assert.False(t, parseable("\n\n\n\n"))
assert.False(t, parseable("1234"))
assert.False(t, parseable("archer"))
assert.False(t, parseable("\"sterling archer\""))
assert.False(t, parseable(",,"))
assert.False(t, parseable("[]"))
assert.False(t, parseable("[,,]"))
assert.False(t, parseable("[\"]"))
assert.False(t, parseable("[:,]"))
assert.False(t, parseable(","))
assert.False(t, parseable("exact words"))
assert.False(t, parseable("his exact words"))
assert.False(t, parseable("\"exact words"))
assert.False(t, parseable("his exact words\""))
assert.False(t, parseable("\"hello\":\"world\" }"))
assert.False(t, parseable("{ \"hello\":\"world\""))
assert.False(t, parseable("{ \"hello world\"}"))
}
func TestHelper(t *testing.T) {
testHelper := newTestHelper()
if testHelper.demoURL == "" {
t.Error("Helper DEMO_URL is empty")
}
}