microcks / microcks/microcks-cli

Refactor : improve TestDeleteContext robustness and isolation using temporary directories

Aperta Adatta ai principianti
#313 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Go
Stelle
52
Fork
68
Merge medio
6h 54m
PR unite (30g)
10

Descrizione

### 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_

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
cli, testing-qa
Tipo di issue
Refactoring
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
84/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.