Skip to content

Commit

Permalink
fix(tests): updates tests to pass FusionAuth client by value.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhartstonge authored and MCBrandenburg committed May 5, 2022
1 parent d1aaefb commit e436067
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fusionauth/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func init() {
}

// fusionauthClient extracts the underlying client from a configured provider
func fusionauthClient() *fusionauth.FusionAuthClient {
func fusionauthClient() fusionauth.FusionAuthClient {
provider, err := testAccProviderFactories[providerFusionauth]()
if err != nil {
log.Println("[ERROR] error getting Fusionauth Provider")
Expand Down
4 changes: 2 additions & 2 deletions fusionauth/resource_fusionauth_generic_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func testAccCheckGenericConnectorExists(resourceName string) resource.TestCheckF
return fmt.Errorf("no resource id is set")
}

connector, faErrs, err := RetrieveConnector(*fusionauthClient(), rs.Primary.ID)
connector, faErrs, err := RetrieveConnector(fusionauthClient(), rs.Primary.ID)
if errs := checkFusionauthErrors(faErrs, err); errs != nil {
return err
}
Expand All @@ -136,7 +136,7 @@ func testAccCheckGenericConnectorDestroy(s *terraform.State) error {

// Ensure we retry for eventual consistency in HA setups.
err := resource.RetryContext(context.Background(), retryTimeout, func() *resource.RetryError {
connector, faErrs, err := RetrieveConnector(*fusionauthClient(), rs.Primary.ID)
connector, faErrs, err := RetrieveConnector(fusionauthClient(), rs.Primary.ID)
if errs := checkFusionauthRetryErrors(faErrs, err); errs != nil {
return errs
}
Expand Down
3 changes: 2 additions & 1 deletion fusionauth/resource_fusionauth_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ func testAccCheckFusionauthKeyExists(resourceName string) resource.TestCheckFunc
return fmt.Errorf("no resource id is set")
}

key, faErrs, err := fusionauthClient().RetrieveKey(rs.Primary.ID)
faClient := fusionauthClient()
key, faErrs, err := faClient.RetrieveKey(rs.Primary.ID)
if errs := checkFusionauthErrors(faErrs, err); errs != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion fusionauth/resource_fusionauth_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ func testAccCheckFusionauthTenantExists(resourceName string) resource.TestCheckF
return fmt.Errorf("no resource id is set")
}

tenant, faErrs, err := fusionauthClient().RetrieveTenant(rs.Primary.ID)
faClient := fusionauthClient()
tenant, faErrs, err := faClient.RetrieveTenant(rs.Primary.ID)
if errs := checkFusionauthErrors(faErrs, err); errs != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions fusionauth/resource_fusionauth_themes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func testAccCheckFusionauthThemeExists(resourceName string) resource.TestCheckFu
return fmt.Errorf("no resource id is set")
}

theme, faErrs, err := fusionauthClient().RetrieveTheme(rs.Primary.ID)
faClient := fusionauthClient()
theme, faErrs, err := faClient.RetrieveTheme(rs.Primary.ID)
if errs := checkFusionauthErrors(faErrs, err); errs != nil {
return err
}
Expand Down Expand Up @@ -212,8 +213,8 @@ func generateFusionAuthTemplate() fusionauth.Templates {
Unauthorized: randString20(),

// TODO(themes): test for deprecated properties
//EmailSend: randString20(),
//RegistrationSend: randString20(),
// EmailSend: randString20(),
// RegistrationSend: randString20(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion fusionauth/resource_fusionauth_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ func testAccCheckFusionauthUserExists(resourceName string) resource.TestCheckFun
return fmt.Errorf("no resource id is set")
}

user, faErrs, err := fusionauthClient().RetrieveUser(rs.Primary.ID)
faClient := fusionauthClient()
user, faErrs, err := faClient.RetrieveUser(rs.Primary.ID)
if err != nil {
// low-level error performing api request
return fmt.Errorf("retrieveuser error: %#+v", err)
Expand Down

0 comments on commit e436067

Please sign in to comment.