diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/pkg/web/request_test.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/go/plugin/go.d/pkg/web/request_test.go (renamed from src/go/collectors/go.d.plugin/pkg/web/request_test.go) | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/pkg/web/request_test.go b/src/go/plugin/go.d/pkg/web/request_test.go index 284cccb93..d39f9a36a 100644 --- a/src/go/collectors/go.d.plugin/pkg/web/request_test.go +++ b/src/go/plugin/go.d/pkg/web/request_test.go @@ -159,6 +159,34 @@ func TestNewHTTPRequest(t *testing.T) { } } +func TestNewRequest(t *testing.T) { + tests := map[string]struct { + url string + path string + wantURL string + }{ + "base url": { + url: "http://127.0.0.1:65535", + path: "/bar", + wantURL: "http://127.0.0.1:65535/bar", + }, + "with path": { + url: "http://127.0.0.1:65535/foo/", + path: "/bar", + wantURL: "http://127.0.0.1:65535/foo/bar", + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + req, err := NewHTTPRequestWithPath(Request{URL: test.url}.Copy(), test.path) + require.NoError(t, err) + + assert.Equal(t, test.wantURL, req.URL.String()) + }) + } +} + func parseBasicAuth(auth string) (username, password string, ok bool) { const prefix = "Basic " if len(auth) < len(prefix) || !strings.EqualFold(auth[:len(prefix)], prefix) { |