技能 编程开发 Finta数据CI/CD集成测试

Finta数据CI/CD集成测试

v20260423
finta-ci-integration
用于自动化Finta融资CRM数据的CI/CD流程。它在每次拉取请求(PR)时运行单元测试,并在合并到主分支时执行集成测试,以确保数据同步逻辑、流水线状态转换以及自动报告工作流的准确性和可靠性。
获取技能
220 次下载
概览

Finta CI Integration

Overview

Set up CI/CD for Finta fundraising integrations: run unit tests with mocked investor pipeline data on every PR, validate live API connectivity for round and investor queries on merge to main. Finta centralizes fundraising CRM data including rounds, investor contacts, and pipeline stages, so CI focuses on verifying data sync logic, pipeline stage transitions, and automated investor reporting workflows.

GitHub Actions Workflow

# .github/workflows/finta-ci.yml
name: Finta CI
on:
  pull_request:
    paths: ['src/finta/**', 'tests/**']
  push:
    branches: [main]

jobs:
  unit-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci
      - run: npm test -- --reporter=verbose

  integration-tests:
    if: github.ref == 'refs/heads/main'
    needs: unit-tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci
      - run: npm run test:integration
        env:
          FINTA_API_KEY: ${{ secrets.FINTA_API_KEY }}

Mock-Based Unit Tests

// tests/finta-service.test.ts
import { describe, it, expect, vi } from 'vitest';
import { summarizeRound } from '../src/finta-service';

const mockRound = {
  id: 'round_seed_01',
  name: 'Seed Round',
  target_amount: 2_000_000,
  raised_amount: 1_250_000,
  investors: [
    { name: 'Acme Ventures', committed: 500_000, stage: 'committed' },
    { name: 'Beta Capital', committed: 750_000, stage: 'committed' },
  ],
};

vi.mock('../src/finta-client', () => ({
  FintaClient: vi.fn().mockImplementation(() => ({
    getRound: vi.fn().mockResolvedValue(mockRound),
    listInvestors: vi.fn().mockResolvedValue({ investors: mockRound.investors, total: 2 }),
    getPipelineSummary: vi.fn().mockResolvedValue({ stages: { committed: 2, in_progress: 3 } }),
  })),
}));

describe('Finta Service', () => {
  it('summarizes fundraising round progress', async () => {
    const summary = await summarizeRound('round_seed_01');
    expect(summary.percentRaised).toBeCloseTo(62.5);
    expect(summary.investorCount).toBe(2);
  });
});

Integration Tests

// tests/integration/finta.integration.test.ts
import { describe, it, expect } from 'vitest';

const hasKey = !!process.env.FINTA_API_KEY;

describe.skipIf(!hasKey)('Finta Live API', () => {
  it('lists fundraising rounds', async () => {
    const res = await fetch('https://api.finta.io/v1/rounds', {
      headers: { Authorization: `Bearer ${process.env.FINTA_API_KEY}` },
    });
    expect(res.status).toBe(200);
    const body = await res.json();
    expect(body).toHaveProperty('rounds');
  });
});

Error Handling

CI IssueCauseFix
401 UnauthorizedInvalid API keyRegenerate at finta.io dashboard
Empty rounds listNo active fundraising roundsCreate a test round in sandbox
Pipeline stage mismatchCustom stage names in workspaceFetch stages dynamically with listStages()
Rate limit (429)Burst of API calls in parallel testsSerialize integration tests or add throttling
Investor data staleWebhook sync delayAdd polling retry for recently updated investors

Resources

Next Steps

For deployment, see finta-deploy-integration.

信息
分类 编程开发
名称 finta-ci-integration
版本 v20260423
大小 3.89KB
更新时间 2026-04-28
语言