@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 78 lines 3.09 KB
Raw
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 import * as BunPath from '@effect/platform-bun/BunPath';
5 import { describe, expect, layer } from '@effect/vitest';
6 import { Effect, Layer } from 'effect';
7 import {
8 RUN_COMPANION_RELEASE_TAG_FILENAME,
9 resolveRunningCliReleaseTag,
10 resolveRunningCliVersion,
11 } from 'src/services/run-companion-modules';
12
13 const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
14
15 describe('running CLI version authority', () => {
16 layer(TestPlatform)(it => {
17 it.effect.each(['@composio/cli@9.9.9', '@composio/cli@0.2.31'])(
18 'uses the compiled version in release builds despite installed tag metadata (%s)',
19 installedTag =>
20 Effect.gen(function* () {
21 const fs = yield* FileSystem.FileSystem;
22 const path = yield* Path.Path;
23 const installDirectory = yield* fs.makeTempDirectoryScoped();
24 const execPath = path.join(installDirectory, 'composio');
25 yield* fs.writeFileString(
26 path.join(installDirectory, RUN_COMPANION_RELEASE_TAG_FILENAME),
27 installedTag
28 );
29
30 expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
31 expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
32 '@composio/cli@0.3.0'
33 );
34 })
35 );
36
37 it.effect('uses the compiled version in a release build without installed metadata', () =>
38 Effect.gen(function* () {
39 const fs = yield* FileSystem.FileSystem;
40 const path = yield* Path.Path;
41 const installDirectory = yield* fs.makeTempDirectoryScoped();
42 const execPath = path.join(installDirectory, 'composio');
43
44 expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
45 expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
46 '@composio/cli@0.3.0'
47 );
48 })
49 );
50
51 it.effect('keeps installed tag fallback behavior in development builds', () =>
52 Effect.gen(function* () {
53 const fs = yield* FileSystem.FileSystem;
54 const path = yield* Path.Path;
55 const installDirectory = yield* fs.makeTempDirectoryScoped();
56 const execPath = path.join(installDirectory, 'composio');
57 const releaseTagPath = path.join(installDirectory, RUN_COMPANION_RELEASE_TAG_FILENAME);
58 yield* fs.writeFileString(releaseTagPath, '@composio/cli@0.2.31');
59
60 expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
61 '0.2.31'
62 );
63 expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
64 '@composio/cli@0.2.31'
65 );
66
67 yield* fs.remove(releaseTagPath);
68
69 expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
70 '0.0.0-development'
71 );
72 expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
73 '@composio/cli@0.0.0-development'
74 );
75 })
76 );
77 });
78 });