oxidecomputer / oxidecomputer/packer-plugin-oxide

Add unit tests for pure logic (Config.Prepare, uniqueSuffix, Artifact, IP filtering)

Open
#106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Packer Plugin Testing
Dominant language
Go
Stars
2
Forks
1
Avg merge
3h 9m
Merged PRs (30d)
3

Description

Problem

Every test in the repo is an acceptance test gated behind PACKER_ACC=1 plus a live Oxide silo, so go test ./... / make test currently exercises nothing. Pure, trivially testable logic has zero coverage:

  • Config.Prepare — defaults (name, hostname, CPUs, memory, boot disk size, VPC, subnet), required-field validation, user_data size limit, warning/error shapes.
  • uniqueSuffix() — build-name sanitization (_-, charset filtering, trimming), PACKER_RUN_UUID truncation to 8 chars.
  • ArtifactId(), String(), State() including the HCP Packer registry image output (registryimage.FromArtifact wiring).
  • External IP filtering in stepInstanceExternalIPList (ephemeral vs floating vs SNAT).
  • Data source Configure validation.

A table-driven unit test of stepImageCreate with a canned state bag would have caught the -force panic (oxidecomputer/packer-plugin-oxide#101).

Fix

Add conventional _test.go unit tests for the above. Steps that need the Oxide API are covered by a separate issue about abstracting the client.

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

Start with go test ./... or make test, then locate Config.Prepare, uniqueSuffix(), Artifact, stepInstanceExternalIPList, data source Configure, and stepImageCreate. Add conventional _test.go coverage for the listed defaults, validation, formatting, filtering, and the canned state-bag case; keep API-dependent steps to the separate abstraction issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.