| 210 | } |
| 211 | |
| 212 | func TestSqlScanner(t *testing.T) { |
| 213 | id1 := New() |
| 214 | id2 := New() |
| 215 | |
| 216 | tests := []struct { |
| 217 | ksuid KSUID |
| 218 | value interface{} |
| 219 | }{ |
| 220 | {Nil, nil}, |
| 221 | {id1, id1.String()}, |
| 222 | {id2, id2.Bytes()}, |
| 223 | } |
| 224 | |
| 225 | for _, test := range tests { |
| 226 | t.Run(fmt.Sprintf("%T", test.value), func(t *testing.T) { |
| 227 | var id KSUID |
| 228 | |
| 229 | if err := id.Scan(test.value); err != nil { |
| 230 | t.Error(err) |
| 231 | } |
| 232 | |
| 233 | if id != test.ksuid { |
| 234 | t.Error("bad KSUID:") |
| 235 | t.Logf("expected %v", test.ksuid) |
| 236 | t.Logf("found %v", id) |
| 237 | } |
| 238 | }) |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | func TestAppend(t *testing.T) { |
| 243 | for _, repr := range []string{"0pN1Own7255s7jwpwy495bAZeEa", "aWgEPTl1tmebfsQzFP4bxwgy80V"} { |