-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser_test.go
50 lines (40 loc) · 1.21 KB
/
parser_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
package asciinema_parser
import (
"context"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestParseV1(t *testing.T) {
asciiCastV1Bytes, err := os.ReadFile("./test_data/ascii_cast_v1.cast")
assert.Nil(t, err)
v1, err := ParseV1(context.Background(), asciiCastV1Bytes)
assert.Nil(t, err)
assert.NotNil(t, v1)
for _, frame := range v1.StdoutFrames {
data, err := frame.GetDataE()
assert.Nil(t, err)
assert.NotEmpty(t, data)
_, err = frame.GetDelayE()
assert.Nil(t, err)
}
}
func TestParseV2(t *testing.T) {
asciiCastV2Bytes, err := os.ReadFile("./test_data/ascii_cast_v2.cast")
assert.Nil(t, err)
v2, err := ParseV2(context.Background(), asciiCastV2Bytes)
assert.Nil(t, err)
assert.NotNil(t, v2)
}
func TestDetectVersion(t *testing.T) {
asciiCastV1Bytes, err := os.ReadFile("./test_data/ascii_cast_v1.cast")
assert.Nil(t, err)
version, err := DetectVersion(context.Background(), string(asciiCastV1Bytes))
assert.Nil(t, err)
assert.Equal(t, Version1, version)
asciiCastV2Bytes, err := os.ReadFile("./test_data/ascii_cast_v2.cast")
assert.Nil(t, err)
version, err = DetectVersion(context.Background(), string(asciiCastV2Bytes))
assert.Nil(t, err)
assert.Equal(t, Version2, version)
}