refactor(corecmd): rename package and finish ContractFinal leaf migration
Move cmdcore to corecmd, declare attendance ContractFinal in helpers, keep Sheet destructive commands --yes-only, and align catalog/policy provenance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
18e32ad09d
commit
7773eb27f1
237 files changed
+105994
-108400
No files matched your search
@@ -3,6 +3,7 @@ package helpers
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -40,16 +41,18 @@ func TestCrossPlatformCoverageSheetChartCommandRemainingCoverage(t *testing.T) {
|
||||
}
|
||||
|
||||
root := newChartCmd()
|
||||
installExampleGlobalFlags(root)
|
||||
deleteCmd := findCoverageSubcommand(t, root, "delete")
|
||||
_ = deleteCmd.Flags().Set("node", "node")
|
||||
_ = deleteCmd.Flags().Set("sheet-id", "sheet")
|
||||
_ = deleteCmd.Flags().Set("chart-id", "chart")
|
||||
oldArgs := os.Args
|
||||
os.Args = []string{"dws", "--yes"}
|
||||
_ = root.PersistentFlags().Set("yes", "true")
|
||||
if err := deleteCmd.RunE(deleteCmd, nil); err != nil {
|
||||
t.Fatalf("confirmed delete: %v", err)
|
||||
}
|
||||
os.Args = []string{"dws"}
|
||||
_ = root.PersistentFlags().Set("yes", "false")
|
||||
// Cancellation must exercise ConfirmSafety; a dry-run caller bypasses it.
|
||||
installScriptedCaller(t, &scriptedToolCaller{})
|
||||
noFile := filepath.Join(t.TempDir(), "no")
|
||||
if err := os.WriteFile(noFile, []byte("no\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -60,12 +63,12 @@ func TestCrossPlatformCoverageSheetChartCommandRemainingCoverage(t *testing.T) {
|
||||
}
|
||||
oldStdin := os.Stdin
|
||||
os.Stdin = stdin
|
||||
deleteCmd.SetIn(stdin)
|
||||
t.Cleanup(func() {
|
||||
os.Args = oldArgs
|
||||
os.Stdin = oldStdin
|
||||
_ = stdin.Close()
|
||||
})
|
||||
if err := deleteCmd.RunE(deleteCmd, nil); err != nil {
|
||||
t.Fatalf("cancelled delete: %v", err)
|
||||
if err := deleteCmd.RunE(deleteCmd, nil); err == nil || !strings.Contains(err.Error(), "用户取消了操作") {
|
||||
t.Fatalf("cancelled delete: error = %v, want 用户取消了操作", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user