(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestApplyIDPSyncMappingDiff(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | |
| 15 | t.Run("with UUIDs", func(t *testing.T) { |
| 16 | t.Parallel() |
| 17 | |
| 18 | id := []uuid.UUID{ |
| 19 | uuid.MustParse("00000000-b8bd-46bb-bb6c-6c2b2c0dd2ea"), |
| 20 | uuid.MustParse("01000000-fbe8-464c-9429-fe01a03f3644"), |
| 21 | uuid.MustParse("02000000-0926-407b-9998-39af62e3d0c5"), |
| 22 | uuid.MustParse("03000000-92f6-4bfd-bba6-0f54667b131c"), |
| 23 | } |
| 24 | |
| 25 | mapping := applyIDPSyncMappingDiff(map[string][]uuid.UUID{}, |
| 26 | []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 27 | {Given: "wibble", Gets: id[0]}, |
| 28 | {Given: "wibble", Gets: id[1]}, |
| 29 | {Given: "wobble", Gets: id[0]}, |
| 30 | {Given: "wobble", Gets: id[1]}, |
| 31 | {Given: "wobble", Gets: id[2]}, |
| 32 | {Given: "wobble", Gets: id[3]}, |
| 33 | {Given: "wooble", Gets: id[0]}, |
| 34 | }, |
| 35 | // Remove takes priority over Add, so `3` should not actually be added. |
| 36 | []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 37 | {Given: "wobble", Gets: id[3]}, |
| 38 | }, |
| 39 | ) |
| 40 | |
| 41 | expected := map[string][]uuid.UUID{ |
| 42 | "wibble": {id[0], id[1]}, |
| 43 | "wobble": {id[0], id[1], id[2]}, |
| 44 | "wooble": {id[0]}, |
| 45 | } |
| 46 | |
| 47 | require.Equal(t, expected, mapping) |
| 48 | |
| 49 | mapping = applyIDPSyncMappingDiff(mapping, |
| 50 | []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 51 | {Given: "wibble", Gets: id[2]}, |
| 52 | {Given: "wobble", Gets: id[3]}, |
| 53 | {Given: "wooble", Gets: id[0]}, |
| 54 | }, |
| 55 | []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 56 | {Given: "wibble", Gets: id[0]}, |
| 57 | {Given: "wobble", Gets: id[1]}, |
| 58 | }, |
| 59 | ) |
| 60 | |
| 61 | expected = map[string][]uuid.UUID{ |
| 62 | "wibble": {id[1], id[2]}, |
| 63 | "wobble": {id[0], id[2], id[3]}, |
| 64 | "wooble": {id[0]}, |
| 65 | } |
| 66 | |
| 67 | require.Equal(t, expected, mapping) |
| 68 | }) |
| 69 |
nothing calls this directly
no test coverage detected