Skip to content

caddytest.Tester should ensure that AppDataDir exists #5974

@tgeoghegan

Description

@tgeoghegan

Caddy (including Caddies run as caddytest.Tester) will create instance.uuid if it doesn't already exist. However, this will fail if caddy.AppDataDir() doesn't already exist, which appears to be the case when caddytest.Tester is used on Linux (though not on Windows or macOS, which I don't understand).

This makes it difficult to use caddytest.Tester to test modules that need caddy.InstanceID() to work. See for example my struggles in mholt/caddy-ratelimit#34, where I resorted to doing os.MkdirAll(caddy.AppDataDir()), which works well enough in CI, but doesn't feel like a great solution.

It'd be nice if caddytest.Tester could consistently guarantee that AppDataDir will exist, or perhaps it could avoid writing the instance ID to disk altogether since a caddytest.Tester instance is not likely to need persistence across restarts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions