Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

857 B
Raw Blame
import { prefetchHogFunctionsStep } from '~/ingestion/common/steps/prefetch-hog-functions-step'
import { PipelineResultType } from '~/ingestion/framework/results'

type TestInput = { team: { id: number } }

function createInput(teamId: number): TestInput {
    return { team: { id: teamId } }
}

describe('prefetchHogFunctionsStep', () => {
    it('warms the hog function cache by team id', async () => {
        const hogTransformer = { prefetchHogFunctionsForTeams: jest.fn().mockResolvedValue(undefined) }
        const step = prefetchHogFunctionsStep<TestInput>(hogTransformer, true)

        const results = await step([createInput(3), createInput(4)])

        expect(results.map((result) => result.type)).toEqual(Array(2).fill(PipelineResultType.OK))
        expect(hogTransformer.prefetchHogFunctionsForTeams).toHaveBeenCalledWith([3, 4])
    })
})