Skip to content

Commit

Permalink
feat(async/await): update commands
Browse files Browse the repository at this point in the history
  • Loading branch information
aorinevo committed Nov 2, 2024
1 parent 01fdc58 commit 930c65c
Show file tree
Hide file tree
Showing 17 changed files with 557 additions and 1,017 deletions.
49 changes: 8 additions & 41 deletions e2e/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,19 @@ Commands:
"
`;
exports[`CLI End-to-End Tests should successfully checkout using repos flag 1`] = `
"Using 2 selected repos
exports[`CLI End-to-End Tests should successfully run apply on a migration 1`] = `""`;
[aorinevo/shepherd-test-repo-1] 1/2
> Running should_migrate steps
✔ Completed all should_migrate steps successfully
> Running post_checkout steps
✔ Completed all post_checkout steps successfully
[aorinevo/shepherd-test-repo-2] 2/2
> Running should_migrate steps
✔ Completed all should_migrate steps successfully
> Running post_checkout steps
✔ Completed all post_checkout steps successfully
Checked out 2 out of 2 repos
"
`;
exports[`CLI End-to-End Tests should successfully run apply on a migration 1`] = `
"
[NerdWalletOSS/shepherd] 1/1
ℹ Running apply steps
$ touch $SHEPHERD_REPO_DIR/testfile.js && echo "some content" > $SHEPHERD_REPO_DIR/testfile.js
Step "touch $SHEPHERD_REPO_DIR/testfile.js && echo "some content" > $SHEPHERD_REPO_DIR/testfile.js" exited with 0
✔ Completed all apply steps successfully
"
`;
exports[`CLI End-to-End Tests should successfully run apply on a migration 2`] = `
"On branch 2024.10.06-test-migration
Untracked files:
(use "git add <file>..." to include in what will be committed)
testfile.js
exports[`CLI End-to-End Tests should successfully run checkout on a migration targeting a single repo 1`] = `
"Loading candidate repos
Loaded 1 repos
Checking out repos
nothing added to commit but untracked files present (use "git add" to track)
"
`;
exports[`CLI End-to-End Tests should successfully run checkout on a migration 1`] = `
"
[NerdWalletOSS/shepherd] 1/1
Checked out repo
> Running should_migrate steps
Completed all should_migrate steps successfully
Completed all should_migrate steps successfully
> Running post_checkout steps
Completed all post_checkout steps successfully
Completed all post_checkout steps successfully
Checked out 1 out of 1 repos
"
Expand Down
29 changes: 19 additions & 10 deletions e2e/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ describe('CLI End-to-End Tests', () => {
);
});

afterAll(() => {
const testMigrationDir = path.resolve(os.homedir(), '.shepherd', '2024.10.06-test-migration');
fs.rmSync(testMigrationDir, { recursive: true });
});

const cliPath = path.resolve(__dirname, '../lib/cli.js');

const runCLI = (args: string) => {
Expand All @@ -33,22 +38,26 @@ describe('CLI End-to-End Tests', () => {
expect(output.split('.').length).toEqual(3);
});

it('should successfully run checkout on a migration', async () => {
it('should successfully run checkout on a migration targeting a single repo', async () => {
const output = runCLI(`checkout ${path.join(__dirname, './assets/checkout-apply')}`);
expect(output).toMatchSnapshot();
});

it('should successfully run checkout on a migration targeting multiple repos', async () => {
const output = runCLI(
`checkout ${path.join(__dirname, './assets/checkout-apply')} --repos="aorinevo/shepherd-test-repo-1,aorinevo/shepherd-test-repo-2"`
);
expect(output).toContain('shepherd-test-repo-1');
expect(output).toContain('shepherd-test-repo-2');
});

it('should successfully run apply on a migration', async () => {
const output = runCLI(`apply ${path.join(__dirname, './assets/checkout-apply')}`);
expect(output).toMatchSnapshot();
const gitDiffOutput = execSync(`cd ${shepherdRepoDir} && git status`, { encoding: 'utf-8' });
expect(output).toContain('shepherd-test-repo-1');
expect(output).toContain('shepherd-test-repo-2');
expect(output).toContain('NerdWalletOSS/shepherd');
const repoDir = path.resolve(shepherdRepoDir, '../../aorinevo/shepherd-test-repo-1');
const gitDiffOutput = execSync(`cd ${repoDir} && git diff`, { encoding: 'utf-8' });
expect(gitDiffOutput).toMatchSnapshot();
});

it('should successfully checkout using repos flag', async () => {
const output = runCLI(
`checkout --repos "aorinevo/shepherd-test-repo-1,aorinevo/shepherd-test-repo-2" ${path.join(__dirname, './assets/checkout-apply')}`
);
expect(output).toMatchSnapshot();
});
});
Loading

0 comments on commit 930c65c

Please sign in to comment.