Agent skill

Assisted Service Writing Unit Tests

by openshift in openshift/assisted-service

A skill your agent uses when writing non-subsystem tests in assisted-service.

Apache-2.0Auto-check passedTesting & QA

Install Assisted Service Writing Unit Tests

skills CLI
$ npx skills add openshift/assisted-service --skill assisted-service-writing-unit-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install openshift/assisted-service assisted-service-writing-unit-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/openshift/assisted-service.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/assisted-service-writing-unit-tests .claude/skills/assisted-service-writing-unit-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
assisted-service-writing-unit-tests
GitHub stars
138
Token cost
~1.9k tokens
SKILL.md length
605 words
Files
1
Skills in repo
2
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when writing non-subsystem tests in assisted-service.

  • Writing non-subsystem tests in assisted-service
  • SKILL.md covers Overview, Quick Reference, When to Use Patterns and Scope, plus 9 more sections
  • Calls go
  • Tasks that involve Unit testing

What it does

Assisted Service Writing Unit Tests is an agent skill from openshift/assisted-service. Use when writing non-subsystem tests in assisted-service.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing. The licence is Apache-2.0.

When your agent uses it

  • Writing non-subsystem tests in assisted-service
  • Tasks that involve Unit testing

Example prompts

  • “/assisted-service-writing-unit-tests”

What it can do on your machine

Read from SKILL.md and the folder at commit e8f87d7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Assisted Service Writing Unit Tests loads about 1.9k tokens when it runs. Until then it costs about 23 tokens; SKILL.md has 605 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~23
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from openshift/assisted-service at commit e8f87d7, republished under its Apache-2.0 licence (© openshift). 605 words, ~1,933 tokens.

Download SKILL.mdSave it as .claude/skills/assisted-service-writing-unit-tests/SKILL.md (or your agent's skills folder).
name
assisted-service-writing-unit-tests
description
Use when writing non-subsystem tests in assisted-service.

Writing Unit Tests in Assisted-Service

Overview

Unit tests in assisted-service use Ginkgo/Gomega BDD framework with gomock for mocking. Core principle: Every gomock controller MUST call ctrl.Finish() in AfterEach to verify mock expectations.

Without ctrl.Finish(), tests pass even when mocks aren't called correctly - silent failures that hide bugs. Tests run against real PostgreSQL (suite or per-test) with automatic cleanup.

Quick Reference

ScenarioPattern
Testing with mocksCreate controller in BeforeEach, call ctrl.Finish() in AfterEach
Testing without mocksUse It() blocks directly or table-driven tests
Database per testPrepareTestDB() in BeforeEach, DeleteTestDB() in AfterEach
Database for suiteInitializeDBTest() in BeforeSuite, TerminateDBTest() in AfterSuite
Event verificationeventstest.NewEventMatcher with matchers
OCP version in testsUse hardcoded strings or common.TestDefaultConfig — do not use TestVersion()

When to Use Patterns

dot
digraph mock_decision {
    "Testing interface deps?" [shape=diamond];
    "Need verify calls or control returns?" [shape=diamond];
    "Use gomock mocks" [shape=box];
    "Use real implementation" [shape=box];

    "Testing interface deps?" -> "Need verify calls or control returns?" [label="yes"];
    "Testing interface deps?" -> "Use real implementation" [label="no"];
    "Need verify calls or control returns?" -> "Use gomock mocks" [label="yes"];
    "Need verify calls or control returns?" -> "Use real implementation" [label="no"];
}
dot
digraph db_decision {
    "Tests share data?" [shape=diamond];
    "Tests modify DB state?" [shape=diamond];
    "Suite-level DB" [shape=box];
    "Per-test DB" [shape=box];

    "Tests share data?" -> "Suite-level DB" [label="yes"];
    "Tests share data?" -> "Tests modify DB state?" [label="no"];
    "Tests modify DB state?" -> "Per-test DB" [label="yes"];
    "Tests modify DB state?" -> "Suite-level DB" [label="no"];
}

Scope

Covers: Non-subsystem tests in internal/ and pkg/ with gomock, Ginkgo/Gomega, database, events.

Does NOT cover: Subsystem tests (subsystem/), E2E, external service integration, performance tests. Subsystem tests use different patterns, including common.TestVersion() for OCP versions.

Test files: *_test.go (same package). Suites: *_suite_test.go.

Critical: Gomock Controllers MUST Call Finish()

Every Describe/Context creating a gomock controller needs ctrl.Finish() in AfterEach. No exceptions.

Without ctrl.Finish():

  • .Times(N) - Expected call count NOT checked
  • .MaxTimes(0) - Unexpected calls NOT caught
  • .Do() / .DoAndReturn() - Mock behavior runs without verification
go
BeforeEach(func() {
    ctrl = gomock.NewController(GinkgoT())
    mockHandler = eventsapi.NewMockHandler(ctrl)
})

AfterEach(func() {
    ctrl.Finish()  // REQUIRED - verifies all EXPECT() constraints
})

Why this matters: Missing ctrl.Finish() causes silent test failures - tests pass even when mocks aren't called correctly. Real bugs found in commit 338133e05 MGMT-23548.

Letter = Spirit: Following the pattern exactly IS following the spirit. This isn't ritual - it's how gomock verification works.

Database Setup Patterns

Suite-level (shared DB, read-only tests):

go
BeforeSuite(func() { common.InitializeDBTest() })
AfterSuite(func() { common.TerminateDBTest() })

Per-test (isolated DB, tests modify state):

go
BeforeEach(func() { db, dbName = common.PrepareTestDB() })
AfterEach(func() { common.DeleteTestDB(db, dbName) })

Event Testing

Use eventstest.NewEventMatcher with specific matchers:

go
mockEvents.EXPECT().SendHostEvent(gomock.Any(), eventstest.NewEventMatcher(
    eventstest.WithNameMatcher(eventgen.HostStatusUpdatedEventName),
    eventstest.WithHostIdMatcher(host.ID.String())))

Matchers: WithNameMatcher, WithHostIdMatcher, WithClusterIdMatcher, WithInfraEnvIdMatcher, WithSeverityMatcher

Table-Driven Tests

DescribeTable (simple cases):

go
DescribeTable("FunctionName",
    func(input string, valid bool) { /* test logic */ },
    Entry("descriptive case 1", "value1", true),
    Entry("descriptive case 2", "value2", false))

Struct array (complex scenarios):

go
tests := []struct{name, input string; valid bool}{
    {name: "case 1", input: "val1", valid: true}}
for _, t := range tests { It(t.name, func() { /* ... */ }) }

Test Structure

Ginkgo hierarchy: Describe("Component") → Context("when X") → It("should Y")

Isolation: No shared state between It blocks. Use BeforeEach for setup.

Gomock matchers: .Times(N), .MaxTimes(0), .AnyTimes(), gomock.Any()

OCP Versions: Use Hardcoded Strings, Not TestVersion()

Do not use common.TestVersion() in non-subsystem tests. TestVersion() resolves versions dynamically from data files and is designed for subsystem tests (subsystem/), which run against the real service. Non-subsystem tests mock version data and should use hardcoded version strings directly.

Correct patterns:

go
OpenshiftVersion: swag.String("4.14"),

Or use the package-level defaults from internal/common/test_configuration.go:

go
OpenshiftVersion: swag.String(common.OpenShiftVersion),
ReleaseVersion:   common.ReleaseVersion,
ReleaseImageUrl:  common.ReleaseImageURL,

See docs/dev/test-versions.md for the TestVersion() API used in subsystem tests.

Show full SKILL.md (233 more words)Show less

Red Flags - Stop and Fix

These thoughts mean STOP - fix the issue:

  • "Tests are passing, mocks must be working" → Add ctrl.Finish() in AfterEach
  • "Too complex to set up properly" → Follow patterns, don't skip structure
  • "Minimum viable test to satisfy review" → Tests must verify behavior, not theater
  • "I'll add cleanup/verification later" → Do it now, tests will merge broken
  • Code has gomock.NewController but no ctrl.Finish() → Silent failures
  • Using common.TestVersion() outside subsystem/ → Wrong pattern; use hardcoded strings or common.TestDefaultConfig

If you're rationalizing shortcuts due to time pressure, the test will be broken. No exceptions.

Common Mistakes

MistakeSymptomFix
Missing ctrl.Finish()Tests pass when mocks not calledAdd ctrl.Finish() in AfterEach
Shared variables between testsFlaky tests, race conditionsMove initialization to BeforeEach
Missing GinkgoT()Controller doesn't report failuresUse gomock.NewController(GinkgoT())
Generic Entry names"test 1", "test 2" in outputDescriptive: "valid IPv4 CIDR"
Wrong DB patternPollution between testsSuite-level for reads, per-test for writes
No event matchersGeneric gomock.Any() for eventsUse eventstest.NewEventMatcher with specific matchers
Using TestVersion()Wrong abstraction for non-subsystem testsUse hardcoded strings or common.TestDefaultConfig

Before Submitting

Check every test file:

  • Every gomock.NewController has ctrl.Finish() in AfterEach
  • No shared state (all setup in BeforeEach)
  • Descriptive names ("valid IPv4 CIDR" not "test 1")
  • Database cleanup if using PrepareTestDB()
  • No TestVersion() usage — use hardcoded strings or common.TestDefaultConfig
  • Tests pass: go test -v ./path/to/package

Red flags: Missing ctrl.Finish() → silent failures. Shared variables → flaky tests.

© openshift, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/assisted-service-writing-unit-tests of openshift/assisted-service.

Open the folder on GitHubat commit e8f87d7

Compare with similar skills

Assisted Service Writing Unit Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Assisted Service Writing Unit Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Assisted Service Writing Unit Tests this skillopenshift/assisted-service138—~1.9kAutomated safety check: PassApache-2.0
TDD WorkflowhellangleZ/burn-in-cceverywhere-ralph11211 repos~2.4kAutomated safety check: PassNone
Testing OpenLogi UIAprilNEA/OpenLogi23k—~1.1kAutomated safety check: PassApache-2.0
Go Testingcxuu/golang-skills1731 repos~1.3kAutomated safety check: PassApache-2.0
Contractssamchon/nestia2.2k—~1.3kAutomated safety check: PassMIT
Cohesion Over TestabilityEpicenterHQ/epicenter4.8k—~2kAutomated safety check: PassCustom licence

Similar skills

  • TDD Workflow

    hellangleZ/burn-in-cceverywhere-ralph

    A skill your agent uses when writing new features, fixing bugs, or refactoring code.

    112 GitHub starsUsed in 11 repos~2.4k tokens
    Testing & QAAuto-check passed
  • Testing OpenLogi UI

    AprilNEA/OpenLogi

    Verifies OpenLogi's native GPUI interface with focused tests, the component gallery and a mock agent, choosing the evidence that fits each change.

    23k GitHub stars~1.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Go Testing

    cxuu/golang-skills

    A skill your agent uses when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff.

    173 GitHub starsUsed in 1 repo~1.3k tokens
    Testing & QAAuto-check passed
  • Contracts

    samchon/nestia

    Defines self-acknowledgments for production declarations and tests.

    2.2k GitHub stars~1.3k tokensUpdated 3 days ago
    Testing & QAAuto-check passed
  • Cohesion Over Testability

    EpicenterHQ/epicenter

    Collapse test-shaped production boundaries while preserving behavior and coverage.

    4.8k GitHub stars~2k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • JS-in-HTML Testing

    liaohch3/claude-tap

    Tests JavaScript embedded in an HTML file in two layers: pytest checks of the logic ported to Python, and Playwright runs in a real browser for the DOM.

    3.3k GitHub stars~924 tokensUpdated today
    Testing & QAAuto-check passed

More from openshift/assisted-service

  • Assisted Service Dev Mode

    openshift/assisted-service

    Build and code-generate assisted-service using skipper with podman.

    138 GitHub stars~1.3k tokensUpdated today
    Auto-check passed

Categories

Questions about Assisted Service Writing Unit Tests

What does Assisted Service Writing Unit Tests do?

A skill your agent uses when writing non-subsystem tests in assisted-service. Assisted Service Writing Unit Tests is an agent skill from openshift/assisted-service. Use when writing non-subsystem tests in assisted-service.

When should I use Assisted Service Writing Unit Tests?

Assisted Service Writing Unit Tests fits situations like: writing non-subsystem tests in assisted-service; tasks that involve Unit testing.

How do I install Assisted Service Writing Unit Tests in Claude Code?

Run `npx skills add openshift/assisted-service --skill assisted-service-writing-unit-tests -a claude-code`. Or copy the skill folder (.agents/skills/assisted-service-writing-unit-tests in openshift/assisted-service) into .claude/skills/assisted-service-writing-unit-tests in your project. Claude Code loads it when a task matches its description.

How do I install Assisted Service Writing Unit Tests in Codex?

Run `npx skills add openshift/assisted-service --skill assisted-service-writing-unit-tests -a codex`. Or copy the skill folder (.agents/skills/assisted-service-writing-unit-tests in openshift/assisted-service) into .agents/skills/assisted-service-writing-unit-tests in your project. Codex loads it when a task matches its description.

Can I use Assisted Service Writing Unit Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add openshift/assisted-service --skill assisted-service-writing-unit-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/assisted-service-writing-unit-tests, .gemini/skills/assisted-service-writing-unit-tests, .github/skills/assisted-service-writing-unit-tests and .opencode/skills/assisted-service-writing-unit-tests in your project.

What does Assisted Service Writing Unit Tests need to run?

Going by SKILL.md and its folder, Assisted Service Writing Unit Tests needs the command-line tools its instructions call (go).

Does Assisted Service Writing Unit Tests access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Assisted Service Writing Unit Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Assisted Service Writing Unit Tests use?

Assisted Service Writing Unit Tests is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Assisted Service Writing Unit Tests use?

About 1.9k tokens (SKILL.md is roughly 7.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Assisted Service Writing Unit Tests?

Skills that share tags, products or a category with Assisted Service Writing Unit Tests: TDD Workflow (hellangleZ/burn-in-cceverywhere-ralph, 112 stars), Testing OpenLogi UI (AprilNEA/OpenLogi, 23k stars), Go Testing (cxuu/golang-skills, 173 stars) and Contracts (samchon/nestia, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Assisted Service Writing Unit Tests?

openshift (a GitHub organization) maintains it in openshift/assisted-service, which has 138 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on October 10, 2026.

Source: openshift/assisted-service on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.