Skip to content

admin: Fix tests locally, properly isolate storage#7486

Merged
mholt merged 5 commits intomasterfrom
fix-admin-test-locally
Feb 17, 2026
Merged

admin: Fix tests locally, properly isolate storage#7486
mholt merged 5 commits intomasterfrom
fix-admin-test-locally

Conversation

@francislavoie
Copy link
Member

The admin tests were failing when I ran it locally:

--- FAIL: TestManageIdentity (0.00s)
    --- FAIL: TestManageIdentity/default_issuer_when_none_specified (0.00s)
        admin_test.go:919: Expected no error but got: localhost: caching certificate: tls: failed to find any PEM data in certificate input
    --- FAIL: TestManageIdentity/custom_issuer (0.00s)
        admin_test.go:919: Expected no error but got: localhost: caching certificate: tls: failed to find any PEM data in certificate input
FAIL

This is because we explicitly use DefaultStorage in admin.go for the local identity (which should not be in synced/clustered storage) but this caused storage overrides in tests to not work so it was using my own user's local storage in ~/.local/share/caddy when it shouldn't.

This adds a test-only local var to override the storage, and at runtime continues to use DefaultStorage as normal. Also improved test cleanup and isolation by using a temp storage instead of testdata/ since new files get written to it during the test.

Assistance Disclosure

Used GitHub Copilot to identify the problem in the tests and implement a fix.

@francislavoie francislavoie requested a review from mholt February 15, 2026 01:52
@francislavoie francislavoie added the bug 🐞 Something isn't working label Feb 15, 2026
@francislavoie francislavoie added this to the v2.11.0 milestone Feb 15, 2026
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you Francis, this looks great actually!

@mholt mholt merged commit 3adcafd into master Feb 17, 2026
29 checks passed
@mholt mholt deleted the fix-admin-test-locally branch February 17, 2026 20:14
This was referenced Feb 20, 2026
@francislavoie francislavoie mentioned this pull request Feb 20, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants