Skip to content

Commit

Permalink
chore(client): rename endpoint builder method
Browse files Browse the repository at this point in the history
Signed-off-by: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com>
  • Loading branch information
lvlcn-t committed Nov 29, 2024
1 parent d7066e7 commit a58557f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (r *restClient) do(ctx context.Context, endpoint *Endpoint, payload, respon
body = bytes.NewBuffer(data)
}

u, err := endpoint.Compile(r.baseURL)
u, err := endpoint.Build(r.baseURL)
if err != nil {
return 0, fmt.Errorf("failed to compile endpoint: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion rest/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func TestClient_Do(t *testing.T) { //nolint:gocyclo // Either complexity or dupl
}

if !tt.invalidURL {
u, e := tt.endpoint.Compile(c.baseURL)
u, e := tt.endpoint.Build(c.baseURL)
if e != nil && !tt.wantErr {
t.Fatalf("Failed to compile endpoint: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions rest/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (e *Endpoint) AddQuery(key, value string) *Endpoint {
return e
}

// Compile compiles the endpoint into a full URL.
func (e *Endpoint) Compile(baseURL string) (string, error) {
// Build builds the full URL for the endpoint using the given base URL.
func (e *Endpoint) Build(baseURL string) (string, error) {
base, err := url.Parse(baseURL)
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion rest/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestEndpoint_Compile(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.e.Compile(tt.baseURL)
got, err := tt.e.Build(tt.baseURL)
if (err != nil) != tt.wantErr {
t.Errorf("Endpoint.Compile() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down

0 comments on commit a58557f

Please sign in to comment.