1package driver 2 3import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/flimzy/testy" 8) 9 10func TestSequenceIDUnmarshal(t *testing.T) { 11 tests := []struct { 12 name string 13 input string 14 15 expected SequenceID 16 err string 17 }{ 18 { 19 name: "Couch 1.6", 20 input: "123", 21 expected: "123", 22 }, 23 { 24 name: "Couch 2.0", 25 input: `"1-seqfoo"`, 26 expected: "1-seqfoo", 27 }, 28 } 29 for _, test := range tests { 30 t.Run(test.name, func(t *testing.T) { 31 var seq SequenceID 32 err := json.Unmarshal([]byte(test.input), &seq) 33 testy.Error(t, test.err, err) 34 if seq != test.expected { 35 t.Errorf("Unexpected result: %s", seq) 36 } 37 }) 38 } 39} 40