Skip to content

Refactor : improve TestDeleteContext robustness and isolation using temporary directories #313

@Manar-Elhabbal7

Description

@Manar-Elhabbal7

Reason/Context

Currently, TestDeleteContext in cmd/context_test.go relies on a hardcoded file path
/testdata/local.config

This approach causes the test to fail on filesystems that do not fully
support Unix-style permissions (such as NTFS or FAT32 partitions commonly used on external drives or
Windows-mounted volumes), as the test attempts to verify restrictive file permissions (0600).

Description

The enhancement involves refactoring the TestDeleteContext function. Instead of using a static file
path, the test will now:

  1. Utilize t.TempDir() to create a unique, isolated directory for each test run.
  2. Construct the configuration file path dynamically using filepath.Join()
  3. Clean up automatically after the test finishes, as t.TempDir() is managed by the Go testing
    package.

Implementation ideas

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions