Fix cmd tests by mocking builtin paths (#37369)

After 07ada3666b, PrepareConsoleLoggerLevel can fail in tests when
InstallLock is true, due to the incorrect config file is loaded. This PR
fixes cmd test setup by mocking builtin paths

Fixes #37368

---------

Co-authored-by: Morgan PEYRE <morgan.peyre@brickcode.tech>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Morgan Peyre
2026-04-22 22:58:59 +02:00
committed by GitHub
parent 9894ebb79c
commit 8cfcef32c6
10 changed files with 101 additions and 76 deletions

View File

@@ -4,6 +4,7 @@
package cmd
import (
"io"
"path/filepath"
"testing"
@@ -107,6 +108,7 @@ func TestCertCommandFailures(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
app := cmdCert()
app.Writer, app.ErrWriter = io.Discard, io.Discard
tempDir := t.TempDir()
certFile := filepath.Join(tempDir, "cert.pem")