fix(audit): initialize writer at execution boundary

This commit is contained in:
修雨 committed 2026-07-16 00:16:39 +08:00
1 parent 0bd767a3fe
commit 765338eb5b
2 files changed
+18 -3

No files matched your search

+7 -1
View File
@@ -15,6 +15,8 @@ package app
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/shortcut/usage"
@@ -100,7 +102,8 @@ func TestCrossPlatformCoverageRecordingToolCaller(t *testing.T) {
}
func TestCrossPlatformCoverageRootPublishesShortcutCommands(t *testing.T) {
t.Setenv("DWS_CONFIG_DIR", t.TempDir())
configDir := t.TempDir()
t.Setenv("DWS_CONFIG_DIR", configDir)
root := NewRootCommand(context.Background())
for _, path := range [][]string{{"shortcut", "list"}, {"calendar", "+today"}} {
cmd, remaining, err := root.Find(path)
@@ -108,4 +111,7 @@ func TestCrossPlatformCoverageRootPublishesShortcutCommands(t *testing.T) {
t.Fatalf("root.Find(%v) = cmd=%v remaining=%v err=%v", path, cmd, remaining, err)
}
}
if _, err := os.Stat(filepath.Join(configDir, "audit", ".audit.lock")); !os.IsNotExist(err) {
t.Fatalf("constructing the root command opened an audit lock: %v", err)
}
}