Skip to content

Commit

Permalink
Fix broken unit tests due to fake client set behavior change
Browse files Browse the repository at this point in the history
Signed-off-by: RainbowMango <[email protected]>
  • Loading branch information
RainbowMango committed Nov 12, 2024
1 parent 914544c commit 7a638f6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/util/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ func TestGetSecret(t *testing.T) {
{
name: "not found error",
args: args{
client: fake.NewSimpleClientset(),
client: fake.NewClientset(),
namespace: metav1.NamespaceDefault,
name: "test",
},
want: nil,
wantErr: true,
},
{
name: "get success",
args: args{
client: fake.NewSimpleClientset(makeSecret("test")),
client: fake.NewClientset(makeSecret("test")),
namespace: metav1.NamespaceDefault,
name: "test",
},
Expand All @@ -116,10 +115,14 @@ func TestGetSecret(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetSecret(tt.args.client, tt.args.namespace, tt.args.name)
if (err != nil) != tt.wantErr {
t.Errorf("GetSecret() error = %v, wantErr %v", err, tt.wantErr)
if (err != nil) && tt.wantErr {
return
}

if (err != nil) && !tt.wantErr {
t.Fatalf("GetSecret() error = %v, wantErr %v", err, tt.wantErr)
}

if !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetSecret() got = %v, want %v", got, tt.want)
}
Expand Down

0 comments on commit 7a638f6

Please sign in to comment.