-
Notifications
You must be signed in to change notification settings - Fork 4
/
helper_test.go
49 lines (43 loc) · 1.19 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
48
49
package neatly
import (
"github.com/stretchr/testify/assert"
"github.com/viant/toolbox"
"testing"
)
func Test_asDataStructure(t *testing.T) {
{
input := `[1,2,3]`
output, err := asDataStructure(input)
assert.Nil(t, err)
assert.EqualValues(t, []interface{}{float64(1), float64(2), float64(3)}, output)
}
{
input := `{"a":1, "b":2}`
output, err := asDataStructure(input)
if assert.Nil(t, err) {
outputMap := toolbox.AsMap(output)
assert.EqualValues(t, map[string]interface{}{
"a": float64(1),
"b": float64(2),
}, outputMap)
}
}
{
input := `{"a":1, "b":2}
{"a2":2, "b3":21}
{"a3":3, "b4:22}
`
output, err := asDataStructure(input)
if assert.Nil(t, err) {
outputMap := toolbox.AsString(output)
assert.EqualValues(t, input, outputMap)
}
}
}
func Test_getAssetURIs(t *testing.T) {
assert.EqualValues(t, []string{"a", "c", "z"}, getAssetURIs("a|c|z"))
assert.EqualValues(t, []string{"a", "c", "z"}, getAssetURIs("a | c | z "))
assert.EqualValues(t, []string{"a", "c", "z"}, getAssetURIs("a c z "))
assert.EqualValues(t, []string{"[a]", "c", "z"}, getAssetURIs("[a] |c | z "))
assert.EqualValues(t, []string{"a", "{c}", "z"}, getAssetURIs("a |{c} | z "))
}