forked from heetch/avro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compat_test.go
46 lines (40 loc) · 989 Bytes
/
compat_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
package avro_test
import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/heetch/avro"
)
var compatStringTests = []struct {
m avro.CompatMode
s string
}{
{0, "NONE"},
{avro.Backward, "BACKWARD"},
{avro.Forward, "FORWARD"},
{avro.Full, "FULL"},
{avro.BackwardTransitive, "BACKWARD_TRANSITIVE"},
{avro.ForwardTransitive, "FORWARD_TRANSITIVE"},
{avro.FullTransitive, "FULL_TRANSITIVE"},
{1 << 10, "UNKNOWN"},
}
func TestCompatString(t *testing.T) {
c := qt.New(t)
for _, test := range compatStringTests {
c.Run(test.s, func(c *qt.C) {
c.Assert(test.m.String(), qt.Equals, test.s)
})
}
}
func TestCompatParse(t *testing.T) {
c := qt.New(t)
for _, test := range compatStringTests {
c.Run(test.s, func(c *qt.C) {
if test.s == "UNKNOWN" {
// We can't return same data we don't know
c.Assert(avro.ParseCompatMode(test.s), qt.Equals, avro.CompatMode(-1))
} else {
c.Assert(avro.ParseCompatMode(test.s), qt.Equals, test.m)
}
})
}
}