@@ -26,6 +26,7 @@ import (
2626 "github.com/onsi/gomega"
2727
2828 corev1 "k8s.io/api/core/v1"
29+ "k8s.io/client-go/rest"
2930)
3031
3132type Test interface {
@@ -54,8 +55,13 @@ func (o errorOption[T]) applyTo(to T) error {
5455var _ Option [any ] = errorOption [any ](nil )
5556
5657func With (t * testing.T ) Test {
58+ return WithConfig (t , nil )
59+ }
60+
61+ func WithConfig (t * testing.T , cfg * rest.Config ) Test {
5762 t .Helper ()
5863 ctx := context .Background ()
64+
5965 if deadline , ok := t .Deadline (); ok {
6066 withDeadline , cancel := context .WithDeadline (ctx , deadline )
6167 t .Cleanup (cancel )
@@ -66,6 +72,7 @@ func With(t *testing.T) Test {
6672 WithT : gomega .NewWithT (t ),
6773 t : t ,
6874 ctx : ctx ,
75+ cfg : cfg ,
6976 }
7077}
7178
@@ -75,6 +82,7 @@ type T struct {
7582 // nolint: containedctx
7683 ctx context.Context
7784 client Client
85+ cfg * rest.Config
7886 outputDir string
7987 once struct {
8088 client sync.Once
@@ -94,7 +102,7 @@ func (t *T) Client() Client {
94102 t .T ().Helper ()
95103 t .once .client .Do (func () {
96104 if t .client == nil {
97- c , err := newTestClient ()
105+ c , err := newTestClient (t . cfg )
98106 if err != nil {
99107 t .T ().Fatalf ("Error creating client: %v" , err )
100108 }
0 commit comments