Skip to content

TestDeleteContext fails #417

@Ansita20

Description

@Ansita20

TestDeleteContext fails because it uses a brittle relative path

Summary

TestDeleteContext in cmd/context_test.go writes its fixture to ./testdata/local.config.
That path depends on the current working directory, so the test fails when it is not run from the package folder.

Error

open ./testdata/local.config: no such file or directory

Expected Behavior

The test should create and use an isolated temporary file path so it does not depend on where the test is launched from.

Actual Behavior

TestDeleteContext fails when the working directory does not contain ./testdata/local.config.

Suggested Fix

Use t.TempDir() to create the config file in a temporary directory, then pass that absolute path through the test instead of using a hardcoded relative path.

Example approach:

tempDir := t.TempDir()
configPath := filepath.Join(tempDir, "local.config")

Acceptance Criteria

  • The test passes when run from the repository root.
  • The test passes when run directly from the cmd package.
  • The test no longer depends on ./testdata/local.config.
  • The test uses temporary isolated filesystem state.

Additional Context

This issue makes the test suite less portable and can cause failures in CI environments or when running tests from different directories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions