Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,17 @@ describe('formatPipelineEventDescription', () => {
expect(out).toContain('deployment_runtime_status_details: (none)')
})

it('omits the desired suffix when desired matches the current status', () => {
it('still appends the desired suffix when desired matches the current status', () => {
const out = formatPipelineEventDescription(
makeEvent({
deployment_resources_status: 'Provisioned',
deployment_resources_desired_status: 'Provisioned'
})
)
expect(out).toContain('deployment_resources_status: Provisioned')
expect(out).not.toContain('desired is')
expect(out).toContain('deployment_resources_status: Provisioned, desired is Provisioned')
})

it('appends "(desired is X)" when desired differs from the current status', () => {
it('appends ", desired is X" when desired differs from the current status', () => {
const out = formatPipelineEventDescription(
makeEvent({
deployment_resources_status: 'Provisioned',
Expand All @@ -368,11 +367,13 @@ describe('formatPipelineEventDescription', () => {
deployment_runtime_desired_status: 'Suspended'
})
)
expect(out).toContain('deployment_resources_status: Provisioned (desired is Stopped)')
expect(out).toContain('deployment_runtime_status: Running (desired is Suspended)')
expect(out).toContain('deployment_resources_status: Provisioned, desired is Stopped')
expect(out).toContain('deployment_runtime_status: Running, desired is Suspended')
})

it('omits the desired suffix when the desired status is nullish', () => {
it('renders the desired suffix verbatim when the desired status is nullish', () => {
// The suffix is now unconditional, so a nullish desired status is
// stringified ("null"/"undefined") rather than suppressed.
const out = formatPipelineEventDescription(
makeEvent({
storage_status: undefined,
Expand All @@ -383,9 +384,8 @@ describe('formatPipelineEventDescription', () => {
})
)
expect(out).toContain('storage_status: (none)')
expect(out).toContain('deployment_resources_status: Stopped')
expect(out).toContain('deployment_runtime_status: (none)')
expect(out).not.toContain('desired is')
expect(out).toContain('deployment_resources_status: Stopped, desired is (none)')
expect(out).toContain('deployment_runtime_status: (none), desired is (none)')
})

it('renders deployment_error fields when present', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,10 @@ const formatScalar = (v: unknown) => (v == null || v === '' ? NONE : String(v))
const formatJson = (v: unknown) =>
v == null || v === '' ? NONE : '\n' + JSON.stringify(v, null, 2)

// Render a status, appending the desired value only when it is present and
// differs from the current one, e.g. "Running (desired is Stopped)".
// Render a status, always appending the desired value:"Running (desired is Stopped)".
const formatStatusWithDesired = (current: unknown, desired: unknown) => {
const base = formatScalar(current)
if (desired == null || desired === '' || String(desired) === String(current)) {
return base
}
return `${base} (desired is ${String(desired)})`
return `${base}, desired is ${desired ?? `(none)`}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this file already defines const NONE = '(none)' just above (line 229) and uses it in formatScalar/formatJson. Consider reusing it here for consistency, e.g. `${base}, desired is ${desired ?? NONE}`. Also the comment on line 235 still shows the old parenthesized example ("Running (desired is Stopped)") — worth updating to the new comma form ("Running, desired is Stopped").

}

export function formatPipelineEventDescription(e: PipelineMonitorEventSelectedInfo): string {
Expand Down
Loading