Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { describe, expect, layer } from '@effect/vitest'; |
| 2 | import { ConfigProvider, Effect } from 'effect'; |
| 3 | import { cli, pkg, TestLive, MockConsole } from 'test/__utils__'; |
| 4 | |
| 5 | describe('CLI: composio', () => { |
| 6 | const testConfigProvider = ConfigProvider.fromEnv({ |
| 7 | env: { DEBUG_OVERRIDE_VERSION: '1.2.3-test' }, |
| 8 | }); |
| 9 | |
| 10 | layer(TestLive())(it => { |
| 11 | it.effect("[Given] no arguments [Then] prints composio's version from package.json", () => |
| 12 | Effect.gen(function* () { |
| 13 | const args = ['version']; |
| 14 | yield* cli(args); |
| 15 | // `composio version` writes the bare semver to stdout via `ui.output()` |
| 16 | // (the data channel scripts parse). Assert the stdout stream directly |
| 17 | // instead of the merged buffer, so decoration written elsewhere can |
| 18 | // never leak into — or be mistaken for — this contract. |
| 19 | const stdoutLines = yield* MockConsole.getLines({ stream: 'stdout' }); |
| 20 | expect(stdoutLines).toEqual([pkg.version]); |
| 21 | }) |
| 22 | ); |
| 23 | }); |
| 24 | |
| 25 | layer(TestLive({ baseConfigProvider: testConfigProvider }))('with config override', it => { |
| 26 | it.effect('[Given] `DEBUG_OVERRIDE_VERSION` env var [Then] prints overridden version', () => |
| 27 | Effect.gen(function* () { |
| 28 | const args = ['version']; |
| 29 | yield* cli(args); |
| 30 | |
| 31 | const stdoutLines = yield* MockConsole.getLines({ stream: 'stdout' }); |
| 32 | expect(stdoutLines).toEqual(['1.2.3-test']); |
| 33 | }) |
| 34 | ); |
| 35 | }); |
| 36 | }); |