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
| 1 | import { describe, it } from '@effect/vitest'; |
| 2 | import { assertEquals } from '@effect/vitest/utils'; |
| 3 | import { ConfigProvider, Effect, type LogLevel, Option, References } from 'effect'; |
| 4 | import { setMinimumLogLevel } from 'src/effects/with-log-level'; |
| 5 | |
| 6 | const withEnv = (entries: ReadonlyArray<readonly [string, string]>) => |
| 7 | Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnvRecord(Object.fromEntries(entries)))); |
| 8 | |
| 9 | const resolveMinimumLogLevel = (logLevelFromCLI: Option.Option<LogLevel.LogLevel>) => |
| 10 | Effect.service(References.MinimumLogLevel).pipe( |
| 11 | Effect.provide(setMinimumLogLevel(logLevelFromCLI)) |
| 12 | ); |
| 13 | |
| 14 | describe('setMinimumLogLevel', () => { |
| 15 | it.effect('[When] neither the flag nor COMPOSIO_LOG_LEVEL is set, it defaults to Info', () => |
| 16 | Effect.gen(function* () { |
| 17 | const level = yield* resolveMinimumLogLevel(Option.none()).pipe(withEnv([])); |
| 18 | assertEquals(level, 'Info'); |
| 19 | }) |
| 20 | ); |
| 21 | |
| 22 | it.effect('[When] only COMPOSIO_LOG_LEVEL is set, it applies', () => |
| 23 | Effect.gen(function* () { |
| 24 | const level = yield* resolveMinimumLogLevel(Option.none()).pipe( |
| 25 | withEnv([['COMPOSIO_LOG_LEVEL', 'Error']]) |
| 26 | ); |
| 27 | assertEquals(level, 'Error'); |
| 28 | }) |
| 29 | ); |
| 30 | |
| 31 | it.effect('[When] only --log-level is set, it applies', () => |
| 32 | Effect.gen(function* () { |
| 33 | const level = yield* resolveMinimumLogLevel(Option.some('Debug')).pipe(withEnv([])); |
| 34 | assertEquals(level, 'Debug'); |
| 35 | }) |
| 36 | ); |
| 37 | |
| 38 | it.effect('[When] both are set, --log-level wins over COMPOSIO_LOG_LEVEL', () => |
| 39 | Effect.gen(function* () { |
| 40 | const level = yield* resolveMinimumLogLevel(Option.some('Debug')).pipe( |
| 41 | withEnv([['COMPOSIO_LOG_LEVEL', 'Error']]) |
| 42 | ); |
| 43 | assertEquals(level, 'Debug'); |
| 44 | }) |
| 45 | ); |
| 46 | }); |