Skip to content

Commit

Permalink
fix: unit TestXxx test
Browse files Browse the repository at this point in the history
  • Loading branch information
vie-serendipity committed May 21, 2024
1 parent 07c4d5e commit d07fbaf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/yurthub/cachemanager/error_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"os"
"path/filepath"
"strings"
"testing"
)

Expand All @@ -30,7 +31,7 @@ func TestXxx(t *testing.T) {
keys []string
err []string
length int
info string
info []string
}{
{
name: "test1",
Expand All @@ -45,7 +46,7 @@ func TestXxx(t *testing.T) {
errors.New("fail3").Error(),
},
length: 3,
info: "fail1\nfail2\nfail3",
info: []string{"fail1", "fail2", "fail3"},
},
}
for _, tc := range testcases {
Expand All @@ -57,8 +58,11 @@ func TestXxx(t *testing.T) {
if ek.length() != tc.length {
t.Errorf("expect length %v, got %v", tc.length, ek.length())
}
if ek.aggregate() != tc.info {
t.Errorf("expect info %v, got %v", tc.info, ek.aggregate())
msg := ek.aggregate()
for i := range tc.info {
if !strings.Contains(msg, tc.info[i]) {
t.Errorf("expect error key's aggregation contain %s", tc.info[i])
}
}
for i := range tc.keys {
ek.del(tc.keys[i])
Expand Down

0 comments on commit d07fbaf

Please sign in to comment.