Skip to content

Replace grep-based weather tests with runtime behavior tests#4

Merged
bgreg merged 3 commits into
fix/weather-and-word-of-day-improvementsfrom
copilot/sub-pr-1-another-one
Dec 22, 2025
Merged

Replace grep-based weather tests with runtime behavior tests#4
bgreg merged 3 commits into
fix/weather-and-word-of-day-improvementsfrom
copilot/sub-pr-1-another-one

Conversation

Copilot AI commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

The weather function tests only verified source code strings via grep, not actual runtime behavior.

Changes

  • Replaced grep tests with integration tests: Mock fetch_with_spinner to test actual function execution instead of searching source code
  • Added 6 behavioral test cases:
    • Early return when location unset
    • Successful weather fetch
    • "Not found" API response → fallback message
    • Empty API response → fallback message
    • URL construction includes location variable
    • Correct curl parameters (flags, timeout, URL format)

Implementation

Tests now mock at the fetch_with_spinner layer rather than curl directly, avoiding subshell scoping issues:

# Before: grep for strings in source
It 'uses location in wttr.in URL'
  When call grep 'wttr.in/\${location}' "$PROJECT_ROOT/lib/app/display.sh"
  The output should not be blank
End

# After: verify runtime behavior
It 'uses location in wttr.in URL construction'
  fetch_with_spinner() {
    shift
    for arg in "$@"; do
      [[ "$arg" == *"wttr.in/New_York"* ]] && echo "New York 🌧️ +65°F" && return 0
    done
    return 1
  }
  GOODMORNING_WEATHER_LOCATION="New_York"
  When call show_weather
  The output should include "🌧️"
End

All 24 tests in display_spec.sh pass.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 22, 2025 22:57
Co-authored-by: bgreg <3711139+bgreg@users.noreply.github.com>
Co-authored-by: bgreg <3711139+bgreg@users.noreply.github.com>

Copilot AI commented Dec 22, 2025

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)
  • git.io
    • Triggering command: /usr/bin/curl curl -fsSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix issues with weather geolocation and offline word of the day Replace grep-based weather tests with runtime behavior tests Dec 22, 2025
Copilot AI requested a review from bgreg December 22, 2025 23:00
@bgreg bgreg marked this pull request as ready for review December 22, 2025 23:01
@bgreg bgreg merged commit c66c9b5 into fix/weather-and-word-of-day-improvements Dec 22, 2025
@bgreg bgreg deleted the copilot/sub-pr-1-another-one branch December 22, 2025 23:01
bgreg added a commit that referenced this pull request Mar 31, 2026
Replace grep-based weather tests with runtime behavior tests
bgreg added a commit that referenced this pull request Jun 30, 2026
Replace grep-based weather tests with runtime behavior tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants