(workspaceID string, count int, timestamp time.Time, passed bool)
| 230 | } |
| 231 | |
| 232 | func createRatelimits(workspaceID string, count int, timestamp time.Time, passed bool) []schema.Ratelimit { |
| 233 | ratelimits := make([]schema.Ratelimit, count) |
| 234 | var remaining uint64 = 50 |
| 235 | if !passed { |
| 236 | remaining = 0 |
| 237 | } |
| 238 | for i := range count { |
| 239 | ratelimits[i] = schema.Ratelimit{ |
| 240 | RequestID: uid.New(uid.RequestPrefix), |
| 241 | Time: timestamp.Add(time.Duration(i) * time.Second).UnixMilli(), |
| 242 | WorkspaceID: workspaceID, |
| 243 | NamespaceID: uid.New(uid.RatelimitNamespacePrefix), |
| 244 | Identifier: uid.New(uid.IdentityPrefix), |
| 245 | Passed: passed, |
| 246 | Latency: rand.Float64() * 10, |
| 247 | OverrideID: "", |
| 248 | Limit: 100, |
| 249 | Remaining: remaining, |
| 250 | ResetAt: timestamp.Add(time.Minute).UnixMilli(), |
| 251 | Tokens: 1, |
| 252 | } |
| 253 | } |
| 254 | return ratelimits |
| 255 | } |
| 256 | |
| 257 | func insertVerifications(t *testing.T, ctx context.Context, conn ch.Conn, verifications []schema.KeyVerification) { |
| 258 | if len(verifications) == 0 { |
no test coverage detected