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.

1.0 KB
Raw Blame
import { describe, expect, test } from 'bun:test'

import { hogDir } from './paths'

describe('hogDir', () => {
    test.each([
        ['macOS', 'darwin', {}, '/Users/ana/Library/Application Support/hog', false],
        ['macOS, run from source', 'darwin', {}, '/Users/ana/Library/Application Support/hog-dev', true],
        ['Linux', 'linux', {}, '/Users/ana/.config/hog', false],
        ['Linux with XDG_CONFIG_HOME', 'linux', { XDG_CONFIG_HOME: '/xdg' }, '/xdg/hog', false],
        ['Linux with a relative XDG_CONFIG_HOME', 'linux', { XDG_CONFIG_HOME: 'xdg' }, '/Users/ana/.config/hog', false],
        [
            'Windows',
            'win32',
            { APPDATA: 'C:\\Users\\ana\\AppData\\Roaming', LOCALAPPDATA: 'C:\\Users\\ana\\AppData\\Local' },
            'C:\\Users\\ana\\AppData\\Local\\hog',
            false,
        ],
    ] as const)('%s', (_name, platform, env, expected, isDevelopment) => {
        expect(hogDir({ platform, env, homeDir: () => '/Users/ana', isDevelopment })).toBe(expected)
    })
})