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, it } from '@effect/vitest'; |
| 2 | import { deepStrictEqual } from '@effect/vitest/utils'; |
| 3 | import { ConfigProvider, Effect } from 'effect'; |
| 4 | import { GITHUB_CONFIG, GITHUB_REPAIR_CONFIG } from 'src/config'; |
| 5 | import * as constants from 'src/constants'; |
| 6 | |
| 7 | const provider = (env: Record<string, string>) => ConfigProvider.fromEnvRecord(env); |
| 8 | |
| 9 | const DEFAULTS = { |
| 10 | apiBaseUrl: constants.GITHUB_REPO.API_BASE_URL, |
| 11 | owner: constants.GITHUB_REPO.OWNER, |
| 12 | repo: constants.GITHUB_REPO.REPO, |
| 13 | tag: undefined, |
| 14 | accessToken: undefined, |
| 15 | }; |
| 16 | |
| 17 | describe('GITHUB_CONFIG', () => { |
| 18 | it.effect('[Given] no overrides [Then] both configs point at the Composio repository', () => |
| 19 | Effect.gen(function* () { |
| 20 | deepStrictEqual(yield* GITHUB_CONFIG.parse(provider({})), DEFAULTS); |
| 21 | deepStrictEqual(yield* GITHUB_REPAIR_CONFIG.parse(provider({})), DEFAULTS); |
| 22 | }) |
| 23 | ); |
| 24 | |
| 25 | it.effect('[Given] COMPOSIO_GITHUB_* [Then] releases are fetched from the override', () => |
| 26 | Effect.gen(function* () { |
| 27 | const env = { |
| 28 | COMPOSIO_GITHUB_API_BASE_URL: 'https://proxy.test', |
| 29 | COMPOSIO_GITHUB_OWNER: 'fork-owner', |
| 30 | COMPOSIO_GITHUB_REPO: '', |
| 31 | COMPOSIO_GITHUB_TAG: '@composio/cli@1.2.3', |
| 32 | COMPOSIO_GITHUB_ACCESS_TOKEN: 'ghp_test', |
| 33 | }; |
| 34 | const expected = { |
| 35 | apiBaseUrl: 'https://proxy.test', |
| 36 | owner: 'fork-owner', |
| 37 | repo: constants.GITHUB_REPO.REPO, |
| 38 | tag: '@composio/cli@1.2.3', |
| 39 | accessToken: 'ghp_test', |
| 40 | }; |
| 41 | deepStrictEqual(yield* GITHUB_CONFIG.parse(provider(env)), expected); |
| 42 | deepStrictEqual(yield* GITHUB_REPAIR_CONFIG.parse(provider(env)), expected); |
| 43 | }) |
| 44 | ); |
| 45 | |
| 46 | it.effect('[Given] unprefixed GITHUB_* [Then] only self-repair honors it, and first', () => |
| 47 | Effect.gen(function* () { |
| 48 | const env = { |
| 49 | GITHUB_TAG: '@composio/cli@9.9.9', |
| 50 | GITHUB_OWNER: 'ci-owner', |
| 51 | COMPOSIO_GITHUB_OWNER: 'fork-owner', |
| 52 | }; |
| 53 | const upgrade = yield* GITHUB_CONFIG.parse(provider(env)); |
| 54 | deepStrictEqual(upgrade.tag, undefined); |
| 55 | deepStrictEqual(upgrade.owner, 'fork-owner'); |
| 56 | const repair = yield* GITHUB_REPAIR_CONFIG.parse(provider(env)); |
| 57 | deepStrictEqual(repair.tag, '@composio/cli@9.9.9'); |
| 58 | deepStrictEqual(repair.owner, 'ci-owner'); |
| 59 | }) |
| 60 | ); |
| 61 | }); |