@@ -155,7 +155,7 @@ func New(t testing.TB, options *Options) *codersdk.Client {
155
155
// the provisioner. This is a temporary function while work is done to
156
156
// standardize how provisioners are registered with coderd. The option
157
157
// to include a provisioner is set to true for convenience.
158
- func NewWithProvisionerCloser (t * testing.T , options * Options ) (* codersdk.Client , io.Closer ) {
158
+ func NewWithProvisionerCloser (t testing.TB , options * Options ) (* codersdk.Client , io.Closer ) {
159
159
if options == nil {
160
160
options = & Options {}
161
161
}
@@ -532,7 +532,7 @@ func NewProvisionerDaemon(t testing.TB, coderAPI *coderd.API) io.Closer {
532
532
return closer
533
533
}
534
534
535
- func NewExternalProvisionerDaemon (t * testing.T , client * codersdk.Client , org uuid.UUID , tags map [string ]string ) io.Closer {
535
+ func NewExternalProvisionerDaemon (t testing.TB , client * codersdk.Client , org uuid.UUID , tags map [string ]string ) io.Closer {
536
536
echoClient , echoServer := provisionersdk .MemTransportPipe ()
537
537
ctx , cancelFunc := context .WithCancel (context .Background ())
538
538
serveDone := make (chan struct {})
@@ -594,15 +594,15 @@ func CreateFirstUser(t testing.TB, client *codersdk.Client) codersdk.CreateFirst
594
594
}
595
595
596
596
// CreateAnotherUser creates and authenticates a new user.
597
- func CreateAnotherUser (t * testing.T , client * codersdk.Client , organizationID uuid.UUID , roles ... string ) (* codersdk.Client , codersdk.User ) {
597
+ func CreateAnotherUser (t testing.TB , client * codersdk.Client , organizationID uuid.UUID , roles ... string ) (* codersdk.Client , codersdk.User ) {
598
598
return createAnotherUserRetry (t , client , organizationID , 5 , roles )
599
599
}
600
600
601
- func CreateAnotherUserMutators (t * testing.T , client * codersdk.Client , organizationID uuid.UUID , roles []string , mutators ... func (r * codersdk.CreateUserRequest )) (* codersdk.Client , codersdk.User ) {
601
+ func CreateAnotherUserMutators (t testing.TB , client * codersdk.Client , organizationID uuid.UUID , roles []string , mutators ... func (r * codersdk.CreateUserRequest )) (* codersdk.Client , codersdk.User ) {
602
602
return createAnotherUserRetry (t , client , organizationID , 5 , roles , mutators ... )
603
603
}
604
604
605
- func createAnotherUserRetry (t * testing.T , client * codersdk.Client , organizationID uuid.UUID , retries int , roles []string , mutators ... func (r * codersdk.CreateUserRequest )) (* codersdk.Client , codersdk.User ) {
605
+ func createAnotherUserRetry (t testing.TB , client * codersdk.Client , organizationID uuid.UUID , retries int , roles []string , mutators ... func (r * codersdk.CreateUserRequest )) (* codersdk.Client , codersdk.User ) {
606
606
req := codersdk.CreateUserRequest {
607
607
Email : namesgenerator .GetRandomName (10 ) + "@coder.com" ,
608
608
Username : randomUsername (t ),
@@ -695,7 +695,7 @@ func createAnotherUserRetry(t *testing.T, client *codersdk.Client, organizationI
695
695
// CreateTemplateVersion creates a template import provisioner job
696
696
// with the responses provided. It uses the "echo" provisioner for compatibility
697
697
// with testing.
698
- func CreateTemplateVersion (t * testing.T , client * codersdk.Client , organizationID uuid.UUID , res * echo.Responses , mutators ... func (* codersdk.CreateTemplateVersionRequest )) codersdk.TemplateVersion {
698
+ func CreateTemplateVersion (t testing.TB , client * codersdk.Client , organizationID uuid.UUID , res * echo.Responses , mutators ... func (* codersdk.CreateTemplateVersionRequest )) codersdk.TemplateVersion {
699
699
t .Helper ()
700
700
data , err := echo .Tar (res )
701
701
require .NoError (t , err )
@@ -737,7 +737,7 @@ func CreateWorkspaceBuild(
737
737
738
738
// CreateTemplate creates a template with the "echo" provisioner for
739
739
// compatibility with testing. The name assigned is randomly generated.
740
- func CreateTemplate (t * testing.T , client * codersdk.Client , organization uuid.UUID , version uuid.UUID , mutators ... func (* codersdk.CreateTemplateRequest )) codersdk.Template {
740
+ func CreateTemplate (t testing.TB , client * codersdk.Client , organization uuid.UUID , version uuid.UUID , mutators ... func (* codersdk.CreateTemplateRequest )) codersdk.Template {
741
741
req := codersdk.CreateTemplateRequest {
742
742
Name : randomUsername (t ),
743
743
VersionID : version ,
@@ -752,7 +752,7 @@ func CreateTemplate(t *testing.T, client *codersdk.Client, organization uuid.UUI
752
752
753
753
// UpdateTemplateVersion creates a new template version with the "echo" provisioner
754
754
// and associates it with the given templateID.
755
- func UpdateTemplateVersion (t * testing.T , client * codersdk.Client , organizationID uuid.UUID , res * echo.Responses , templateID uuid.UUID ) codersdk.TemplateVersion {
755
+ func UpdateTemplateVersion (t testing.TB , client * codersdk.Client , organizationID uuid.UUID , res * echo.Responses , templateID uuid.UUID ) codersdk.TemplateVersion {
756
756
ctx := context .Background ()
757
757
data , err := echo .Tar (res )
758
758
require .NoError (t , err )
@@ -768,15 +768,15 @@ func UpdateTemplateVersion(t *testing.T, client *codersdk.Client, organizationID
768
768
return templateVersion
769
769
}
770
770
771
- func UpdateActiveTemplateVersion (t * testing.T , client * codersdk.Client , templateID , versionID uuid.UUID ) {
771
+ func UpdateActiveTemplateVersion (t testing.TB , client * codersdk.Client , templateID , versionID uuid.UUID ) {
772
772
err := client .UpdateActiveTemplateVersion (context .Background (), templateID , codersdk.UpdateActiveTemplateVersion {
773
773
ID : versionID ,
774
774
})
775
775
require .NoError (t , err )
776
776
}
777
777
778
778
// AwaitTemplateVersionJobRunning waits for the build to be picked up by a provisioner.
779
- func AwaitTemplateVersionJobRunning (t * testing.T , client * codersdk.Client , version uuid.UUID ) codersdk.TemplateVersion {
779
+ func AwaitTemplateVersionJobRunning (t testing.TB , client * codersdk.Client , version uuid.UUID ) codersdk.TemplateVersion {
780
780
t .Helper ()
781
781
782
782
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitShort )
@@ -807,7 +807,7 @@ func AwaitTemplateVersionJobRunning(t *testing.T, client *codersdk.Client, versi
807
807
808
808
// AwaitTemplateVersionJobCompleted waits for the build to be completed. This may result
809
809
// from cancelation, an error, or from completing successfully.
810
- func AwaitTemplateVersionJobCompleted (t * testing.T , client * codersdk.Client , version uuid.UUID ) codersdk.TemplateVersion {
810
+ func AwaitTemplateVersionJobCompleted (t testing.TB , client * codersdk.Client , version uuid.UUID ) codersdk.TemplateVersion {
811
811
t .Helper ()
812
812
813
813
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
@@ -826,7 +826,7 @@ func AwaitTemplateVersionJobCompleted(t *testing.T, client *codersdk.Client, ver
826
826
}
827
827
828
828
// AwaitWorkspaceBuildJobCompleted waits for a workspace provision job to reach completed status.
829
- func AwaitWorkspaceBuildJobCompleted (t * testing.T , client * codersdk.Client , build uuid.UUID ) codersdk.WorkspaceBuild {
829
+ func AwaitWorkspaceBuildJobCompleted (t testing.TB , client * codersdk.Client , build uuid.UUID ) codersdk.WorkspaceBuild {
830
830
t .Helper ()
831
831
832
832
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitShort )
@@ -897,7 +897,7 @@ func AwaitWorkspaceAgents(t testing.TB, client *codersdk.Client, workspaceID uui
897
897
// CreateWorkspace creates a workspace for the user and template provided.
898
898
// A random name is generated for it.
899
899
// To customize the defaults, pass a mutator func.
900
- func CreateWorkspace (t * testing.T , client * codersdk.Client , organization uuid.UUID , templateID uuid.UUID , mutators ... func (* codersdk.CreateWorkspaceRequest )) codersdk.Workspace {
900
+ func CreateWorkspace (t testing.TB , client * codersdk.Client , organization uuid.UUID , templateID uuid.UUID , mutators ... func (* codersdk.CreateWorkspaceRequest )) codersdk.Workspace {
901
901
t .Helper ()
902
902
req := codersdk.CreateWorkspaceRequest {
903
903
TemplateID : templateID ,
@@ -915,7 +915,7 @@ func CreateWorkspace(t *testing.T, client *codersdk.Client, organization uuid.UU
915
915
}
916
916
917
917
// TransitionWorkspace is a convenience method for transitioning a workspace from one state to another.
918
- func MustTransitionWorkspace (t * testing.T , client * codersdk.Client , workspaceID uuid.UUID , from , to database.WorkspaceTransition ) codersdk.Workspace {
918
+ func MustTransitionWorkspace (t testing.TB , client * codersdk.Client , workspaceID uuid.UUID , from , to database.WorkspaceTransition ) codersdk.Workspace {
919
919
t .Helper ()
920
920
ctx := context .Background ()
921
921
workspace , err := client .Workspace (ctx , workspaceID )
@@ -939,7 +939,7 @@ func MustTransitionWorkspace(t *testing.T, client *codersdk.Client, workspaceID
939
939
}
940
940
941
941
// MustWorkspace is a convenience method for fetching a workspace that should exist.
942
- func MustWorkspace (t * testing.T , client * codersdk.Client , workspaceID uuid.UUID ) codersdk.Workspace {
942
+ func MustWorkspace (t testing.TB , client * codersdk.Client , workspaceID uuid.UUID ) codersdk.Workspace {
943
943
t .Helper ()
944
944
ctx := context .Background ()
945
945
ws , err := client .Workspace (ctx , workspaceID )
@@ -952,7 +952,7 @@ func MustWorkspace(t *testing.T, client *codersdk.Client, workspaceID uuid.UUID)
952
952
953
953
// RequestExternalAuthCallback makes a request with the proper OAuth2 state cookie
954
954
// to the external auth callback endpoint.
955
- func RequestExternalAuthCallback (t * testing.T , providerID string , client * codersdk.Client ) * http.Response {
955
+ func RequestExternalAuthCallback (t testing.TB , providerID string , client * codersdk.Client ) * http.Response {
956
956
client .HTTPClient .CheckRedirect = func (req * http.Request , via []* http.Request ) error {
957
957
return http .ErrUseLastResponse
958
958
}
@@ -980,7 +980,7 @@ func RequestExternalAuthCallback(t *testing.T, providerID string, client *coders
980
980
// NewGoogleInstanceIdentity returns a metadata client and ID token validator for faking
981
981
// instance authentication for Google Cloud.
982
982
// nolint:revive
983
- func NewGoogleInstanceIdentity (t * testing.T , instanceID string , expired bool ) (* idtoken.Validator , * metadata.Client ) {
983
+ func NewGoogleInstanceIdentity (t testing.TB , instanceID string , expired bool ) (* idtoken.Validator , * metadata.Client ) {
984
984
keyID , err := cryptorand .String (12 )
985
985
require .NoError (t , err )
986
986
claims := jwt.MapClaims {
@@ -1042,7 +1042,7 @@ func NewGoogleInstanceIdentity(t *testing.T, instanceID string, expired bool) (*
1042
1042
1043
1043
// NewAWSInstanceIdentity returns a metadata client and ID token validator for faking
1044
1044
// instance authentication for AWS.
1045
- func NewAWSInstanceIdentity (t * testing.T , instanceID string ) (awsidentity.Certificates , * http.Client ) {
1045
+ func NewAWSInstanceIdentity (t testing.TB , instanceID string ) (awsidentity.Certificates , * http.Client ) {
1046
1046
privateKey , err := rsa .GenerateKey (rand .Reader , 2048 )
1047
1047
require .NoError (t , err )
1048
1048
@@ -1102,7 +1102,7 @@ func NewAWSInstanceIdentity(t *testing.T, instanceID string) (awsidentity.Certif
1102
1102
1103
1103
// NewAzureInstanceIdentity returns a metadata client and ID token validator for faking
1104
1104
// instance authentication for Azure.
1105
- func NewAzureInstanceIdentity (t * testing.T , instanceID string ) (x509.VerifyOptions , * http.Client ) {
1105
+ func NewAzureInstanceIdentity (t testing.TB , instanceID string ) (x509.VerifyOptions , * http.Client ) {
1106
1106
privateKey , err := rsa .GenerateKey (rand .Reader , 2048 )
1107
1107
require .NoError (t , err )
1108
1108
@@ -1182,7 +1182,7 @@ type nopcloser struct{}
1182
1182
func (nopcloser ) Close () error { return nil }
1183
1183
1184
1184
// SDKError coerces err into an SDK error.
1185
- func SDKError (t * testing.T , err error ) * codersdk.Error {
1185
+ func SDKError (t testing.TB , err error ) * codersdk.Error {
1186
1186
var cerr * codersdk.Error
1187
1187
require .True (t , errors .As (err , & cerr ))
1188
1188
return cerr
0 commit comments