-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
caddytest.Tester
should ensure that AppDataDir
exists
#5974
Comments
Good point. Redoing our caddytest package was on my list for 2.8 (then the baby came early, then life got busy, and I got behind on my backlog, so testing has been deferred another cycle again, sorry). But in the meantime we could probably work in a fix for this before then. |
I can take a look at this! |
Sounds good, let us know if you have questions @armadi1809 |
@mholt I guess this can be resolved in two ways: 1- Inside the Which one is preferred? After a quick search through the code base, it doesn't look like the UUID file is being used somewhere else other than where it's being created (i.e. inside the |
@armadi1809 I think 1 is best. A call to @tgeoghegan AppDataDir() honors XDG env vars, so maybe tests could set XDG_DATA_HOME to a temporary directory. |
Caddy (including Caddies run as
caddytest.Tester
) will createinstance.uuid
if it doesn't already exist. However, this will fail ifcaddy.AppDataDir()
doesn't already exist, which appears to be the case whencaddytest.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 needcaddy.InstanceID()
to work. See for example my struggles in mholt/caddy-ratelimit#34, where I resorted to doingos.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 thatAppDataDir
will exist, or perhaps it could avoid writing the instance ID to disk altogether since acaddytest.Tester
instance is not likely to need persistence across restarts.The text was updated successfully, but these errors were encountered: