# test.deploy/core/steps/shell.fixture.ts

> 42 lines of code and 9 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-deploy-core-steps-shell-fixture-ts
Source text: https://banes-lab.com/source/testing/test.deploy/core/steps/shell.fixture.ts.txt

Listed in [test.deploy/core/steps](https://banes-lab.com/api/source/testing/test.deploy/core/steps.md), after [test.deploy/core/steps/setup.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/setup.step.test.ts.md) and before [test.deploy/core/steps/site.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/site.step.test.ts.md).

## Definitions

- `FakeShell` (interface_declaration, line 3, exported)
- `fakeShell` (lexical_declaration, line 9, exported)
- `commands` (lexical_declaration, line 10, exported)
- `downloads` (lexical_declaration, line 11, exported)
- `uploads` (lexical_declaration, line 12, exported)
- `ok` (lexical_declaration, line 36, exported)
- `fakeJournal` (lexical_declaration, line 40, exported)
- `lines` (lexical_declaration, line 41, exported)
- `log` (lexical_declaration, line 42, exported)

## Contained in

- [test.deploy/core/steps](https://banes-lab.com/anatomy/testing/folder-testing-test-deploy-core-steps.md)

## Source

```typescript
import type { CommandResult, Journal, Shell } from "@banes-lab/deploy/types/deployment.types.ts";

export interface FakeShell extends Shell {
    readonly commands: string[];
    readonly downloads: (readonly [string, string])[];
    readonly uploads: (readonly [string, string])[];
}

export const fakeShell = function fakeShell(answer: (command: string) => CommandResult): FakeShell {
    const commands: string[] = [];
    const downloads: (readonly [string, string])[] = [];
    const uploads: (readonly [string, string])[] = [];
    return {
        commands,
        connect: async () => {
            await Promise.resolve();
        },
        dispose: () => {},
        download: async (local, remote) => {
            downloads.push([local, remote]);
            await Promise.resolve();
        },
        downloads,
        run: async (command) => {
            commands.push(command);
            return answer(command);
        },
        upload: async (local, remote) => {
            uploads.push([local, remote]);
            await Promise.resolve();
        },
        uploads,
    };
};

export const ok = function ok(stdout = ""): CommandResult {
    return { code: 0, stderr: "", stdout };
};

export const fakeJournal = function fakeJournal(): Journal & { readonly lines: string[] } {
    const lines: string[] = [];
    const log = (message: string): void => {
        lines.push(message);
    };
    return { error: log, lines, log, mark: log, summary: () => lines.join("\n") };
};
```
