(t *testing.T)
| 18 | } |
| 19 | |
| 20 | func TestGenerateDeviceAndUserCodeCollision(t *testing.T) { |
| 21 | deviceCodeSet := make(map[string]bool) |
| 22 | userCodeSet := make(map[string]bool) |
| 23 | |
| 24 | for i := 0; i < 10000; i++ { |
| 25 | authCode, err := generateDeviceAndUserCode() |
| 26 | if err != nil { |
| 27 | t.Error(err) |
| 28 | } |
| 29 | if len(authCode.DeviceCode) != 32 { |
| 30 | t.Errorf("device code length is incorrect; got %d, want 32", len(authCode.DeviceCode)) |
| 31 | } |
| 32 | if len(authCode.UserCode) != 8 { |
| 33 | t.Errorf("user code length is incorrect; got %d, want 8", len(authCode.UserCode)) |
| 34 | } |
| 35 | if deviceCodeSet[authCode.DeviceCode] { |
| 36 | t.Errorf("device code collision: %s", authCode.DeviceCode) |
| 37 | } |
| 38 | if userCodeSet[authCode.UserCode] { |
| 39 | t.Errorf("user code collision: %s", authCode.UserCode) |
| 40 | } |
| 41 | deviceCodeSet[authCode.DeviceCode] = true |
| 42 | userCodeSet[authCode.UserCode] = true |
| 43 | } |
| 44 | } |
nothing calls this directly
no test coverage detected