Skip to content

Commit

Permalink
test: squash some extra test output (#1446)
Browse files Browse the repository at this point in the history
## Description

Cut / reduce some (_extra_) lengthy test output in order to make the
output more manageable / scannable.

## Related Issue

Fixes to #1358 

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

Co-authored-by: Case Wylie <[email protected]>
  • Loading branch information
btlghrants and cmwylie19 authored Nov 20, 2024
1 parent 097a86f commit feff8ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 3 additions & 5 deletions journey/pepr-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ export function peprDev() {

// Convert buffer to string
const strData = data.toString();
console.log(strData);

// Check if any expected lines are found
expectedLines = expectedLines.filter(expectedLine => {
// Check if the expected line is found in the output, ignoring whitespace
return !strData.replace(/\s+/g, " ").includes(expectedLine);
});

console.info(`Expected lines remaining: ${expectedLines.length}`);
console.debug(`Remaining expected lines: ${expectedLines}`);

// If all expected lines are found, resolve the promise
if (expectedLines.length < 1) {
if (expectedLines.length > 0) {
console.log(`still waiting on ${expectedLines.length} lines...`);
} else {
// Abort all further processing
success = true;

Expand Down
15 changes: 14 additions & 1 deletion src/cli/init/walkthrough.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors

import { describe, expect, it } from "@jest/globals";
import { afterAll, beforeAll, describe, expect, jest, it } from "@jest/globals";
import prompts from "prompts";
import {
walkthrough,
Expand All @@ -12,7 +12,20 @@ import {
setErrorBehavior,
} from "./walkthrough";

let consoleLog: jest.Spied<typeof console.log>;
let consoleError: jest.Spied<typeof console.error>;

describe("when processing input", () => {
beforeAll(() => {
consoleLog = jest.spyOn(console, "log").mockImplementation(() => {});
consoleError = jest.spyOn(console, "error").mockImplementation(() => {});
});

afterAll(() => {
consoleLog.mockRestore();
consoleError.mockRestore();
});

describe("walkthough() returns expected results", () => {
it.each([
//Test flag combinations with [["$FLAG", ...]]
Expand Down

0 comments on commit feff8ee

Please sign in to comment.