microcks / microcks/microcks-cli

Refactor : improve TestDeleteContext robustness and isolation using temporary directories

Open Beginner friendly
#313 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
52
Forks
68
Avg merge
6h 54m
Merged PRs (30d)
10

Description

### 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 f`ilepath.Join()`
3. Clean up automatically after the test finishes, as `t.TempDir()` is managed by the Go testing
package.

### Implementation ideas

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open cmd/context_test.go and start with TestDeleteContext. Run that test to observe its current behavior, then verify that the test uses t.TempDir() and filepath.Join() instead of the hardcoded path. Done means the test remains isolated, cleans up automatically, and passes on its supported filesystems.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, testing-qa
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.