-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_ism_test.go
51 lines (39 loc) · 1.22 KB
/
parse_ism_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
package libphonelabgo
import (
phonelab "github.com/shaseley/phonelab-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestIMSParser(t *testing.T) {
t.Parallel()
assert := assert.New(t)
require := require.New(t)
parser := NewIMSLifeCycleParser()
payload := `{"Action":"onStartInputView","Time":1492483700860,"UpTimeNs":158108566813,"UpTimeMs":158108,"timestamp":1492483700860,"uptimeNanos":158108619260,"LogFormat":"1.1"}`
expected := &IMSLifeCycleLog{
PLLog: phonelab.PLLog{
LogFormat: "1.1",
UptimeNanos: 158108619260,
Timestamp: 1492483700860,
},
UpTimeNs: 158108566813,
Action: "onStartInputView",
}
res, err := parser.Parse(payload)
require.Nil(err)
assert.Equal(expected, res)
payload = `{"Action":"onFinishInputView","Time":1492483718447,"UpTimeNs":175695147952,"UpTimeMs":175695,"timestamp":1492483718447,"uptimeNanos":175695167900,"LogFormat":"1.1"}`
expected = &IMSLifeCycleLog{
PLLog: phonelab.PLLog{
LogFormat: "1.1",
UptimeNanos: 175695167900,
Timestamp: 1492483718447,
},
UpTimeNs: 175695147952,
Action: "onFinishInputView",
}
res, err = parser.Parse(payload)
require.Nil(err)
assert.Equal(expected, res)
}