This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Set the path properly for calls to api-service (#470)
* fix: Set the path properly for calls to api-service Signed-off-by: Florian Bacher <[email protected]> * added test Signed-off-by: Florian Bacher <[email protected]> * removed debug output Signed-off-by: Florian Bacher <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestAPIHandler_getAPIServicePath(t *testing.T) { | ||
type fields struct { | ||
BaseURL string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
}{ | ||
{ | ||
name: "remove controlPlane path suffix", | ||
fields: fields{ | ||
BaseURL: "my-api.sh/api/controlPlane", | ||
}, | ||
want: "my-api.sh/api", | ||
}, | ||
{ | ||
name: "don't modify anything for internal API calls", | ||
fields: fields{ | ||
BaseURL: "api-service", | ||
}, | ||
want: "api-service", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
a := &APIHandler{ | ||
BaseURL: tt.fields.BaseURL, | ||
} | ||
assert.Equalf(t, tt.want, a.getAPIServicePath(), "getAPIServicePath()") | ||
}) | ||
} | ||
} |