refactor(server): rename tests folder
This commit is contained in:
@@ -2,8 +2,8 @@ import type Redis from 'ioredis'
|
||||
|
||||
import type { Env } from './libs/env'
|
||||
import type { OtelInstance } from './libs/otel'
|
||||
import type { BillingMqService } from './services/billing-mq'
|
||||
import type { BillingService } from './services/billing-service'
|
||||
import type { BillingMqService } from './services/billing/billing-mq'
|
||||
import type { BillingService } from './services/billing/billing-service'
|
||||
import type { CharacterService } from './services/characters'
|
||||
import type { ChatService } from './services/chats'
|
||||
import type { ConfigKVService } from './services/config-kv'
|
||||
@@ -40,8 +40,8 @@ import { createFluxRoutes } from './routes/flux'
|
||||
import { createProviderRoutes } from './routes/providers'
|
||||
import { createStripeRoutes } from './routes/stripe'
|
||||
import { createV1CompletionsRoutes } from './routes/v1completions'
|
||||
import { createBillingMqService } from './services/billing-mq'
|
||||
import { createBillingService } from './services/billing-service'
|
||||
import { createBillingMqService } from './services/billing/billing-mq'
|
||||
import { createBillingService } from './services/billing/billing-service'
|
||||
import { createCharacterService } from './services/characters'
|
||||
import { createChatService } from './services/chats'
|
||||
import { createConfigKVService } from './services/config-kv'
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { createServerCli, parseServerRole } from '../run'
|
||||
|
||||
describe('server cli', () => {
|
||||
it('parses supported roles', () => {
|
||||
expect(parseServerRole(['api'])).toBe('api')
|
||||
expect(parseServerRole(['billing-consumer'])).toBe('billing-consumer')
|
||||
})
|
||||
|
||||
it('returns null for unsupported or missing roles', () => {
|
||||
expect(parseServerRole([])).toBeNull()
|
||||
expect(parseServerRole(['unknown'])).toBeNull()
|
||||
})
|
||||
|
||||
it('registers all supported roles with cac', () => {
|
||||
const cli = createServerCli()
|
||||
|
||||
expect(cli.commands.map(command => command.name)).toEqual(expect.arrayContaining([
|
||||
'api',
|
||||
'billing-consumer',
|
||||
]))
|
||||
})
|
||||
})
|
||||
@@ -6,9 +6,9 @@ import { createDrizzle, migrateDatabase } from '../libs/db'
|
||||
import { parseEnv } from '../libs/env'
|
||||
import { initializeExternalDependency } from '../libs/external-dependency'
|
||||
import { createRedis } from '../libs/redis'
|
||||
import { createBillingConsumerHandler } from '../services/billing-consumer-handler'
|
||||
import { createBillingMqService } from '../services/billing-mq'
|
||||
import { createBillingMqWorker } from '../services/billing-mq-worker'
|
||||
import { createBillingConsumerHandler } from '../services/billing/billing-consumer-handler'
|
||||
import { createBillingMqService } from '../services/billing/billing-mq'
|
||||
import { createBillingMqWorker } from '../services/billing/billing-mq-worker'
|
||||
|
||||
function parsePositiveInteger(rawValue: string, envKey: string): number {
|
||||
const parsed = Number(rawValue)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Env } from '../libs/env'
|
||||
import type { RevenueMetrics } from '../libs/otel'
|
||||
import type { BillingService } from '../services/billing-service'
|
||||
import type { BillingService } from '../services/billing/billing-service'
|
||||
import type { ConfigKVService } from '../services/config-kv'
|
||||
import type { FluxService } from '../services/flux'
|
||||
import type { StripeService } from '../services/stripe'
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import type { StripeCheckoutSession, StripeInvoice } from '../../schemas/stripe'
|
||||
import type { BillingService } from '../../services/billing-service'
|
||||
import type { BillingService } from '../../services/billing/billing-service'
|
||||
import type { ConfigKVService } from '../../services/config-kv'
|
||||
import type { FluxService } from '../../services/flux'
|
||||
import type { StripeService } from '../../services/stripe'
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import type { BillingMqService } from '../../services/billing-mq'
|
||||
import type { BillingService } from '../../services/billing-service'
|
||||
import type { BillingMqService } from '../../services/billing/billing-mq'
|
||||
import type { BillingService } from '../../services/billing/billing-service'
|
||||
import type { ConfigKVService } from '../../services/config-kv'
|
||||
import type { FluxService } from '../../services/flux'
|
||||
import type { HonoEnv } from '../../types/hono'
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Context } from 'hono'
|
||||
|
||||
import type { LlmMetrics } from '../libs/otel'
|
||||
import type { UsageInfo } from '../services/billing'
|
||||
import type { BillingMqService } from '../services/billing-mq'
|
||||
import type { BillingService } from '../services/billing-service'
|
||||
import type { UsageInfo } from '../services/billing/billing'
|
||||
import type { BillingMqService } from '../services/billing/billing-mq'
|
||||
import type { BillingService } from '../services/billing/billing-service'
|
||||
import type { ConfigKVService } from '../services/config-kv'
|
||||
import type { FluxService } from '../services/flux'
|
||||
import type { HonoEnv } from '../types/hono'
|
||||
@@ -16,7 +16,7 @@ import { bodyLimit } from 'hono/body-limit'
|
||||
import { authGuard } from '../middlewares/auth'
|
||||
import { configGuard } from '../middlewares/config-guard'
|
||||
import { rateLimiter } from '../middlewares/rate-limit'
|
||||
import { calculateFluxFromUsage, extractUsageFromBody } from '../services/billing'
|
||||
import { calculateFluxFromUsage, extractUsageFromBody } from '../services/billing/billing'
|
||||
import { createPaymentRequiredError } from '../utils/error'
|
||||
import { nanoid } from '../utils/id'
|
||||
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
import type { Database } from '../libs/db'
|
||||
import type { Database } from '../../libs/db'
|
||||
import type { BillingStreamMessage } from './billing-mq'
|
||||
|
||||
import { useLogger } from '@guiiai/logg'
|
||||
|
||||
import * as fluxAuditSchema from '../schemas/flux-audit-log'
|
||||
import * as fluxLedgerSchema from '../schemas/flux-ledger'
|
||||
import * as llmRequestLogSchema from '../schemas/llm-request-log'
|
||||
import * as fluxAuditSchema from '../../schemas/flux-audit-log'
|
||||
import * as fluxLedgerSchema from '../../schemas/flux-ledger'
|
||||
import * as llmRequestLogSchema from '../../schemas/llm-request-log'
|
||||
|
||||
const logger = useLogger('billing-consumer-handler').useGlobalConfig()
|
||||
|
||||
+10
-10
@@ -1,22 +1,22 @@
|
||||
import type Redis from 'ioredis'
|
||||
|
||||
import type { Database } from '../libs/db'
|
||||
import type { RevenueMetrics } from '../libs/otel'
|
||||
import type { Database } from '../../libs/db'
|
||||
import type { RevenueMetrics } from '../../libs/otel'
|
||||
import type { ConfigKVService } from '../config-kv'
|
||||
import type { BillingEvent } from './billing-events'
|
||||
import type { BillingMqService } from './billing-mq'
|
||||
import type { ConfigKVService } from './config-kv'
|
||||
|
||||
import { useLogger } from '@guiiai/logg'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
import { createPaymentRequiredError } from '../utils/error'
|
||||
import { nanoid } from '../utils/id'
|
||||
import { fluxRedisKey } from './flux'
|
||||
import { createPaymentRequiredError } from '../../utils/error'
|
||||
import { nanoid } from '../../utils/id'
|
||||
import { fluxRedisKey } from '../flux'
|
||||
|
||||
import * as fluxSchema from '../schemas/flux'
|
||||
import * as fluxAuditSchema from '../schemas/flux-audit-log'
|
||||
import * as fluxLedgerSchema from '../schemas/flux-ledger'
|
||||
import * as stripeSchema from '../schemas/stripe'
|
||||
import * as fluxSchema from '../../schemas/flux'
|
||||
import * as fluxAuditSchema from '../../schemas/flux-audit-log'
|
||||
import * as fluxLedgerSchema from '../../schemas/flux-ledger'
|
||||
import * as stripeSchema from '../../schemas/stripe'
|
||||
|
||||
const logger = useLogger('billing-service')
|
||||
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
import type Redis from 'ioredis'
|
||||
|
||||
import type { Database } from '../../libs/db'
|
||||
import type { Database } from '../../../libs/db'
|
||||
import type { createConfigKVService } from '../../config-kv'
|
||||
import type { BillingMqService } from '../billing-mq'
|
||||
import type { createConfigKVService } from '../config-kv'
|
||||
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { mockDB } from '../../libs/mock-db'
|
||||
import { mockDB } from '../../../libs/mock-db'
|
||||
import { createBillingService } from '../billing-service'
|
||||
|
||||
import * as schema from '../../schemas'
|
||||
import * as schema from '../../../schemas'
|
||||
|
||||
function createMockConfigKV(overrides: Record<string, number> = {}): ReturnType<typeof createConfigKVService> {
|
||||
const defaults: Record<string, number> = { INITIAL_USER_FLUX: 100, FLUX_PER_CENT: 1, FLUX_PER_REQUEST: 1, ...overrides }
|
||||
Reference in New Issue
Block a user