From 176b4f2502640f60e16afe48f933ced76942ffe1 Mon Sep 17 00:00:00 2001 From: "Angel M. Adames" Date: Tue, 20 Feb 2024 11:50:33 -0400 Subject: [PATCH] chore: Add more Compose command tests --- src/commands/compose/index.ts | 2 +- test/commands/compose.test.ts | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/commands/compose/index.ts b/src/commands/compose/index.ts index d913fcb..e130ecc 100644 --- a/src/commands/compose/index.ts +++ b/src/commands/compose/index.ts @@ -16,7 +16,7 @@ export const composeCommand = () => { 'Uses Compose under the hood.', ) .addCommand(composeShowArgsCommand()) - .action(async (options) => { + .action(() => { const config = projectConfig(); const args = process.argv.slice(3); diff --git a/test/commands/compose.test.ts b/test/commands/compose.test.ts index 2e0b5ba..e721a4b 100644 --- a/test/commands/compose.test.ts +++ b/test/commands/compose.test.ts @@ -1,23 +1,27 @@ import { describe, expect, test } from 'bun:test'; import { projectConfig } from '../../src/config/project'; import { composeExecParams, composeFiles } from '../../src/utils/compose'; +import { composeCommand } from '../../src/commands/compose'; describe("Command: 'compose'", () => { const config = projectConfig(); - test('Returns compose files string', () => { - const composeFileString = composeFiles({}); + test('Returns compose exec params', () => { const composeSettingsString = composeExecParams(); - - expect(composeFileString).toBeArray(); expect(composeSettingsString).toContain( - `--env-file ${projectConfig().paths.env_file}`, + `--env-file ${config.paths.env_file}`, ); expect(composeSettingsString).toContain( - `--project-name ${projectConfig().compose.project_name}`, + `--project-name ${config.compose.project_name}`, ); }); + test('Returns compose files params', () => { + const files = composeFiles({}); + expect(files).toBeArray(); + expect(files.join(' ').split(' ')).toContain('--file'); + }) + test('Returns error when no arguments', () => { const command = Bun.spawnSync(['./cli.ts', 'compose']); expect(command.stdout.toString()).toContain( @@ -25,4 +29,12 @@ describe("Command: 'compose'", () => { ); expect(command.exitCode).toEqual(1); }); + + test('Returns both files and exec params', () => { + const command = Bun.spawnSync(['./cli.ts', 'compose', 'show-args']); + expect(command.stdout.toString()).toContain('Compose command params:'); + expect(command.stdout.toString()).toContain('Compose files params:'); + expect(command.exitCode).toEqual(0); + }) }); +