Skip to content

Bug: Undefined baseUrl and origin Constants in API Service Test #479

Open
@Shweta-281

Description

@Shweta-281

Describe your issue

The api_service_test.dart file contains unit tests for the Taskwarrior API service. During testing, the baseUrl (API endpoint) and origin (application identifier) constants were referenced but not defined, leading to compilation errors. These constants are critical for constructing the correct API request URL in the fetchTasks function. Without proper definitions, the test suite fails, hindering development and CI/CD pipelines.

Steps to reproduce

  1. Define Constants in the Test File:
    Add baseUrl and origin directly to the test file as placeholders to resolve compilation issues.

  2. Example:
    const String baseUrl = 'https://your-api-base-url.com';
    const String origin = 'your-application-origin';
    This ensures immediate test stability while allowing maintainers to later refactor these values into a shared configuration file.

  3. Future Improvement (Optional):
    Centralize configuration (e.g., via config.dart or environment variables) to avoid hardcoding values across the codebase.
    Use mocking for baseUrl and origin in tests to decouple from environment-specific settings.

What was the expected result?

No response

Put here any screenshots or videos (optional)

No response

How can we contact you (optional)

No response

Would you like to work on this issue?

Yes

By submitting this issue, I have confirmed that:

  • I have starred the repo ⭐ and watched 👀 it on GitHub and followed the contribution guidelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions