Skip to content

Add unit tests for BufferWriter in cmd/ci/writer.go #3567

@Ankitsinghsisodya

Description

@Ankitsinghsisodya

Issue: Add unit tests for BufferWriter in cmd/ci/writer.go

Summary

The BufferWriter test double in cmd/ci/writer.go currently has zero test
coverage
on its Write and Exist methods.

Motivation

  • BufferWriter is used as an in-memory WorkflowWriter fake in tests. If its
    behaviour changes silently, higher-level tests can start passing or failing
    for the wrong reason.
  • Its behaviour is small but non-trivial: Write must record the path,
    replace existing buffer contents, and Exist must reflect whether any data
    has been written.

Proposed Change

Add a new file cmd/ci/writer_test.go (package ci_test) that covers:

Scenario Method
Exist returns false before any write BufferWriter.Exist
Exist returns true after a write BufferWriter.Exist
Write stores the provided path BufferWriter.Write
Consecutive writes reset the buffer instead of appending BufferWriter.Write

Affected Files

  • New: cmd/ci/writer_test.go

Labels

kind/test, good first issue

Metadata

Metadata

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