# test.deploy/core/steps/remote.step.test.ts

> 24 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-deploy-core-steps-remote-step-test-ts
Source text: https://banes-lab.com/source/testing/test.deploy/core/steps/remote.step.test.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/release.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/release.step.test.ts.md) and before [test.deploy/core/steps/search.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/search.step.test.ts.md).

## Contained in

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

## Source

```typescript
import { ROOT_CLEAN, STALE_REMOVED } from "@banes-lab/deploy/configuration/strings/deployment.strings.ts";
import { describe, expect, it } from "vitest";
import { fakeJournal, fakeShell, ok } from "./shell.fixture.ts";
import { REMOTE_ROOT } from "@banes-lab/deploy/configuration/constants/deployment.constants.ts";
import { pruneRemoteRoot } from "@banes-lab/deploy/core/steps/remote.step.ts";

const LEGACY = `${REMOTE_ROOT}/node_modules`;
const ECOSYSTEM = `${REMOTE_ROOT}/ecosystem.config.cjs`;

describe("pruneRemoteRoot", () => {
    it("lists the root without the owned folders and leaves a clean root alone", async () => {
        const shell = fakeShell(() => ok(""));
        const journal = fakeJournal();
        expect(await pruneRemoteRoot(shell, journal)).toStrictEqual([]);
        expect(shell.commands[0]).toContain(`find ${REMOTE_ROOT} -mindepth 1 -maxdepth 1 ! -name web ! -name staging`);
        expect(journal.lines).toContain(ROOT_CLEAN);
    });

    it("removes every stale entry with file operations only, never touching a process manager", async () => {
        const shell = fakeShell((command) => ok(command.startsWith("find") ? `${LEGACY}\n${ECOSYSTEM}\n` : ""));
        const journal = fakeJournal();
        expect(await pruneRemoteRoot(shell, journal)).toStrictEqual([LEGACY, ECOSYSTEM]);
        expect(shell.commands).toStrictEqual([shell.commands[0], `rm -rf ${LEGACY} ${ECOSYSTEM}`]);
        expect(shell.commands.some((command) => command.includes("pm2"))).toBe(false);
        expect(journal.lines).toContain(STALE_REMOVED + LEGACY);
    });
});
```
