Skip to content

fix: replace clear=True with surgical env cleanup in session tests#1279

Open
ItIsUday wants to merge 1 commit intomainfrom
fix/session-test-env-isolation
Open

fix: replace clear=True with surgical env cleanup in session tests#1279
ItIsUday wants to merge 1 commit intomainfrom
fix/session-test-env-isolation

Conversation

@ItIsUday
Copy link
Copy Markdown

Six session tests were failing due to missing /state endpoint mocks when using clear=True to remove GitHub Actions environment variables. The clear=True approach wiped all environment variables, including SMART_TESTS_BASE_URL, causing the CLI to use production URLs while mocks were configured for localhost:8080.

This commit replaces clear=True with a _clean_github_env() helper
Benefits:

  • Tests now inherit SMART_TESTS_BASE_URL from shell environment
  • No redundant HTTP mock setup needed in each test
  • Single source of truth for GitHub variable cleanup

Six session tests were failing due to missing /state endpoint mocks when
using clear=True to remove GitHub Actions environment variables. The
clear=True approach wiped all environment variables, including
SMART_TESTS_BASE_URL, causing the CLI to use production URLs while mocks
were configured for localhost:8080.

This commit replaces clear=True with a _clean_github_env() helper that:
- Explicitly clears only GITHUB_* variables that affect test behavior
- Preserves inherited environment like SMART_TESTS_BASE_URL, PATH, etc.
- Eliminates need for manual re-adding of environment variables
- Makes tests work in any environment (local dev, CI, Docker)

Benefits:
- Tests now inherit SMART_TESTS_BASE_URL from shell environment
- No redundant HTTP mock setup needed in each test
- Single source of truth for GitHub variable cleanup
- Production-ready: works with corporate proxies, custom URLs, etc.

Fixes 6 test failures in SessionTest:
- test_run_session
- test_run_session_with_flavor
- test_run_session_with_observation
- test_run_session_with_timestamp
- test_run_session_with_link
- test_run_session_with_no_build

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ItIsUday ItIsUday self-assigned this Apr 15, 2026
@ItIsUday ItIsUday requested review from a team, Konboi and gayanW and removed request for Konboi and gayanW April 15, 2026 12:23
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.

1 participant