pull/31899/merge
Terry Howe 4 days ago committed by GitHub
commit a8b9632d44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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")
}

@ -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")
}

@ -115,5 +115,5 @@ 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")
}

@ -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")
}

@ -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")
}

@ -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")
}

@ -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{

Loading…
Cancel
Save