整理证书部署清理测试

整理部署清理测试替身格式并修正旧备份断言提示,保持测试行为与实现一致。
This commit is contained in:
xuans 2026-09-27 09:56:14 +08:00
parent f5ce3077d1
commit e9738eab06

View File

@ -39,31 +39,18 @@ func newMemoryClient() *memoryClient {
func (c *memoryClient) MkdirAll(context.Context, string) error { return nil } func (c *memoryClient) MkdirAll(context.Context, string) error { return nil }
func (c *memoryClient) List(_ context.Context, directory string) ([]string, error) { func (c *memoryClient) List(_ context.Context, directory string) ([]string, error) {
entries := make([]string, 0) entries := make([]string, 0)
prefix := strings.TrimSuffix(directory, "/") + "/" prefix := strings.TrimSuffix(directory, "/") + "/"
for filePath := range c.files { for filePath := range c.files {
if !strings.HasPrefix(filePath, prefix) { if !strings.HasPrefix(filePath, prefix) {
continue continue
} }
name := strings.TrimPrefix(filePath, prefix) name := strings.TrimPrefix(filePath, prefix)
if name == "" || strings.Contains(name, "/") { if name == "" || strings.Contains(name, "/") {
continue continue
} }
entries = append(entries, filePath) entries = append(entries, filePath)
} }
return entries, nil return entries, nil
} }
@ -176,7 +163,7 @@ func TestDeployReplacesFilesAndCleansBackups(t *testing.T) {
} }
} }
if backupCount != 0 { if backupCount != 0 {
t.Fatalf("成功部署后应保留三份远程备份:%d", backupCount) t.Fatalf("成功部署后不应残留远程备份:%d", backupCount)
} }
} }