(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func TestUUIDMapping(t *testing.T) { |
| 37 | t.Parallel() |
| 38 | |
| 39 | for _, dsn := range dbx.GetDSNs(t, false) { |
| 40 | dsn := dsn |
| 41 | t.Run("dsn="+dsn.Name, func(t *testing.T) { |
| 42 | t.Parallel() |
| 43 | reg := driver.NewTestRegistry(t, dsn) |
| 44 | c, err := reg.PopConnection(context.Background()) |
| 45 | require.NoError(t, err) |
| 46 | |
| 47 | testUUID := uuid.Must(uuid.NewV4()) |
| 48 | |
| 49 | for _, tc := range []struct { |
| 50 | desc string |
| 51 | mappings interface{} |
| 52 | assertErr assert.ErrorAssertionFunc |
| 53 | }{{ |
| 54 | desc: "empty should not fail on constraint", |
| 55 | mappings: &sql.UUIDMapping{}, |
| 56 | assertErr: assert.NoError, |
| 57 | }, { |
| 58 | desc: "empty strings should not fail on constraint", |
| 59 | mappings: &sql.UUIDMapping{ID: uuid.Nil}, |
| 60 | assertErr: assert.NoError, |
| 61 | }, { |
| 62 | desc: "single with string rep should succeed", |
| 63 | mappings: &sql.UUIDMapping{StringRepresentation: "foo"}, |
| 64 | assertErr: assert.NoError, |
| 65 | }, { |
| 66 | desc: "two with same uuid should fail on constraint", |
| 67 | mappings: &[]sql.UUIDMapping{ |
| 68 | {ID: testUUID, StringRepresentation: "foo"}, |
| 69 | {ID: testUUID, StringRepresentation: "bar"}, |
| 70 | }, |
| 71 | assertErr: assertCheckErr, |
| 72 | }, { |
| 73 | desc: "two with same rep should succeed", |
| 74 | mappings: &[]sql.UUIDMapping{ |
| 75 | {ID: uuid.Must(uuid.NewV4()), StringRepresentation: "bar"}, |
| 76 | {ID: uuid.Must(uuid.NewV4()), StringRepresentation: "bar"}, |
| 77 | }, |
| 78 | assertErr: assert.NoError, |
| 79 | }} { |
| 80 | tc := tc |
| 81 | t.Run("case="+tc.desc, func(t *testing.T) { |
| 82 | t.Parallel() |
| 83 | err := c.Create(tc.mappings) |
| 84 | tc.assertErr(t, err) |
| 85 | }) |
| 86 | } |
| 87 | }) |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected