Skip to content

test : added unit tests for upstash-rest.ts#2836

Open
tmdeveloper007 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#2830
Open

test : added unit tests for upstash-rest.ts#2836
tmdeveloper007 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#2830

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2830.

Summary of What Has Been Done: Added vitest unit tests for the Upstash Redis REST helpers in src/lib/upstash-rest.ts, covering getUpstashConfig, upstashPipeline, upstashRateLimitFixedWindow, and upstashTryAcquireLock.

Changes Made:

  • Test getUpstashConfig: null when missing env vars, returns config when both present
  • Test upstashPipeline: empty array when not configured, empty on fetch failure, parsed JSON on success
  • Test upstashRateLimitFixedWindow: allowed when not configured or fetch fails, allowed when count is NaN, blocked when over limit
  • Test upstashTryAcquireLock: false when not configured, true when SET returns OK, false when SET returns null

Impact it Made: Upstash Redis powers distributed rate limiting and locking. Test coverage validates behavior across all configuration and response scenarios.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for upstash-rest.ts

1 participant