Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
[HOTFIX] Director is failing due to DB indicator errors (#3895)
Browse files Browse the repository at this point in the history
* [HOTFIX] Director is failing due to DB indicator errors

* Update fetcher_on_demand_test.go
  • Loading branch information
dzahariev authored May 22, 2024
1 parent 0a771b7 commit 4f97b4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/kyma-incubator/compass/components/director/pkg/correlation"
"github.com/kyma-incubator/compass/components/director/pkg/log"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -53,8 +52,7 @@ func NewFetchOnDemandService(client Client, config FetchOnDemandAPIConfig) Fetch
// FetchOnDemand calls an API which fetches details for the given tenant from an external tenancy service, stores the tenant in the Compass DB and returns 200 OK if the tenant was successfully created. Note that tenants with slash in their name are ignored!
func (s *fetchOnDemandService) FetchOnDemand(ctx context.Context, tenant, parentTenant string) error {
if strings.Contains(tenant, "/") {
log.C(ctx).Warn(fmt.Sprintf("ignore fetching of tenant %s, as fetch on demand cannot be used for URM tenants that contains slashes", tenant))
return nil
return fmt.Errorf("ignore fetching of tenant %s, as fetch on demand cannot be used for URM tenants that contains slashes", tenant)
}
reqURL := s.buildRequestURL(tenant, parentTenant)
req, err := http.NewRequest(http.MethodPost, reqURL, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestFetchOnDemand(t *testing.T) {
tenantIDWithSlash = "/path/tenant"
parentTenantID = "8d4842ed-0307-4808-85d5-6bbed114c4ff"
testErr = errors.New("error")
ignoreFetchErr = errors.New("ignore fetching of tenant")
)

testCases := []struct {
Expand Down Expand Up @@ -58,13 +59,14 @@ func TestFetchOnDemand(t *testing.T) {
},
},
{
Name: "Success when tenant id contain slash",
Name: "Error when tenant id contain slash",
TenantID: tenantIDWithSlash,
ParentTenantID: "",
Client: func() *automock.Client {
client := &automock.Client{}
return client
},
ExpectedErrorMsg: ignoreFetchErr.Error(),
},
{
Name: "Error when cannot make the request",
Expand Down

0 comments on commit 4f97b4d

Please sign in to comment.