Skip to content

test: cover getUpstashConfig missing-env and empty-string cases (#3031)#3192

Open
aaniya22 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
aaniya22:test/upstash-rest-getUpstashConfig
Open

test: cover getUpstashConfig missing-env and empty-string cases (#3031)#3192
aaniya22 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
aaniya22:test/upstash-rest-getUpstashConfig

Conversation

@aaniya22

Copy link
Copy Markdown
Contributor

Summary

Adds test coverage for getUpstashConfig()'s two untested branches — both env vars set, and either env var being an empty string — closing the gap identified in the issue.

Closes #3031


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Added getUpstashConfig returns { url, token } when both env vars are set to test/upstash-rest.test.mjs
  • Added getUpstashConfig returns null when either env var is an empty string to test/upstash-rest.test.mjs
  • No changes to src/lib/upstash-rest.ts itself — test-only PR

How to Test

  1. Checkout this branch
  2. Run node --test test/upstash-rest.test.mjs
  3. Confirm all 6 tests pass (4 pre-existing + 2 new)

Expected result: All tests pass, including the two new cases covering getUpstashConfig's previously-untested branches.


Screenshots / Recordings

Not applicable — test-only change, no UI impact.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

Not applicable — no UI impact.


Additional Context

Issue #3031 asked for a new test/upstash-rest.test.ts using Vitest, but a test/upstash-rest.test.mjs using Node's built-in node:test runner already exists and covers most of upstash-rest.ts (including upstashRateLimitFixedWindow and upstashTryAcquireLock). Rather than create a second, competing test file for the same module in a different framework, I extended the existing file with the two specific getUpstashConfig scenarios the issue called out that weren't yet covered. Happy to convert to a standalone Vitest file instead if that's preferred — just let me know and I'll follow up.

@github-actions

Copy link
Copy Markdown

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors!

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels Jul 13, 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

@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

The test cases themselves are correct and useful, but they're added to test/upstash-rest.test.mjs — and the vitest config only includes test/**/*.test.{ts,tsx} (see vitest.config), so .mjs test files aren't picked up by the suite and won't run in CI. As-is these assertions never execute. Please port them into a .ts vitest spec (e.g. test/upstash-rest.test.ts using import { describe, it, expect } from "vitest") so they actually run. Then I'll merge.

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 getUpstashConfig

2 participants