This commit is contained in:
Terry Howe 2026-05-19 09:30:38 +05:30 committed by GitHub
commit ccce843531
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 10 deletions

View file

@ -490,5 +490,5 @@ data:
is.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}

View file

@ -1295,5 +1295,5 @@ func TestInstallRelease_WaitOptionsPassedDownstream(t *testing.T) {
is.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}

View file

@ -118,7 +118,7 @@ func TestReleaseTesting_WaitOptionsPassedDownstream(t *testing.T) {
is.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}
func TestGetContainerLogs_MultipleContainers(t *testing.T) {

View file

@ -81,5 +81,5 @@ func TestRollback_WaitOptionsPassedDownstream(t *testing.T) {
is.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}

View file

@ -204,5 +204,5 @@ func TestUninstall_WaitOptionsPassedDownstream(t *testing.T) {
is.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}

View file

@ -800,5 +800,5 @@ func TestUpgradeRelease_WaitOptionsPassedDownstream(t *testing.T) {
req.NoError(err)
// Verify that WaitOptions were passed to GetWaiter
is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter")
is.NotEmpty(failer.GetRecordedWaitOptions(), "WaitOptions should be passed to GetWaiter")
}

View file

@ -19,6 +19,7 @@ package fake
import (
"io"
"sync"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -47,8 +48,9 @@ type FailingKubeClient struct {
WaitForDeleteError error
WatchUntilReadyError error
WaitDuration time.Duration
// RecordedWaitOptions stores the WaitOptions passed to GetWaiter for testing
RecordedWaitOptions []kube.WaitOption
// recordedWaitOptions stores the WaitOptions passed to GetWaiter for testing
recordedWaitOptions []kube.WaitOption
mu sync.Mutex
}
var _ kube.Interface = &FailingKubeClient{}
@ -158,9 +160,19 @@ func (f *FailingKubeClient) GetWaiter(ws kube.WaitStrategy) (kube.Waiter, error)
return f.GetWaiterWithOptions(ws)
}
// GetRecordedWaitOptions returns the recorded WaitOptions in a thread-safe manner.
func (f *FailingKubeClient) GetRecordedWaitOptions() []kube.WaitOption {
f.mu.Lock()
defer f.mu.Unlock()
dst := make([]kube.WaitOption, len(f.recordedWaitOptions))
copy(dst, f.recordedWaitOptions)
return dst
}
func (f *FailingKubeClient) GetWaiterWithOptions(ws kube.WaitStrategy, opts ...kube.WaitOption) (kube.Waiter, error) {
// Record the WaitOptions for testing
f.RecordedWaitOptions = append(f.RecordedWaitOptions, opts...)
f.mu.Lock()
f.recordedWaitOptions = append(f.recordedWaitOptions, opts...)
f.mu.Unlock()
waiter, _ := f.PrintingKubeClient.GetWaiterWithOptions(ws, opts...)
printingKubeWaiter, _ := waiter.(*PrintingKubeWaiter)
return &FailingKubeWaiter{