(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestUUIDVersionErrors(t *testing.T) { |
| 146 | // UUId V1 Version |
| 147 | id := FromStringOrNil("e86160d3-beff-443c-b9b5-1f8197ccb12e") |
| 148 | _, err := TimestampFromV1(id) |
| 149 | if err == nil { |
| 150 | t.Error("expected an error") |
| 151 | return |
| 152 | } |
| 153 | expectedErr := "uuid: e86160d3-beff-443c-b9b5-1f8197ccb12e is version 4, not version 1" |
| 154 | if err.Error() != expectedErr { |
| 155 | t.Errorf("unexpected error '%s' != '%s'", err.Error(), expectedErr) |
| 156 | } |
| 157 | |
| 158 | // UUId V2 Version |
| 159 | id = FromStringOrNil("e86160d3-beff-443c-b9b5-1f8197ccb12e") |
| 160 | _, err = TimestampFromV6(id) |
| 161 | if err == nil { |
| 162 | t.Error("expected an error") |
| 163 | return |
| 164 | } |
| 165 | expectedErr = "uuid: e86160d3-beff-443c-b9b5-1f8197ccb12e is version 4, not version 6" |
| 166 | if err.Error() != expectedErr { |
| 167 | t.Errorf("unexpected error '%s' != '%s'", err.Error(), expectedErr) |
| 168 | } |
| 169 | |
| 170 | // UUId V7 Version |
| 171 | id = FromStringOrNil("e86160d3-beff-443c-b9b5-1f8197ccb12e") |
| 172 | _, err = TimestampFromV7(id) |
| 173 | if err == nil { |
| 174 | t.Error("expected an error") |
| 175 | return |
| 176 | } |
| 177 | expectedErr = "uuid: e86160d3-beff-443c-b9b5-1f8197ccb12e is version 4, not version 7" |
| 178 | if err.Error() != expectedErr { |
| 179 | t.Errorf("unexpected error '%s' != '%s'", err.Error(), expectedErr) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // This test cannot be run in parallel with other tests since it modifies the |
| 184 | // global state |
nothing calls this directly
no test coverage detected