mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Extend unittest coverage in util
This commit is contained in:
parent
7a5347803a
commit
33bd6bd787
6 changed files with 599 additions and 1 deletions
36
util/url_test.go
Normal file
36
util/url_test.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// This file is Free Software under the Apache-2.0 License
|
||||
// without warranty, see README.md and LICENSES/Apache-2.0.txt for details.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2022 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
|
||||
// Software-Engineering: 2022 Intevation GmbH <https://intevation.de>
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBaseUrl(t *testing.T) {
|
||||
for _, x := range [][2]string{
|
||||
{`http://example.com`, `http://example.com/`},
|
||||
{`scheme://example.com`, `scheme://example.com/`},
|
||||
{`https://example.com`, `https://example.com/`},
|
||||
{`https://example.com:8080/`, `https://example.com:8080/`},
|
||||
{`https://user@example.com:8080/`, `https://user@example.com:8080/`},
|
||||
{`https://user@example.com:8080/resource`, `https://user@example.com:8080/`},
|
||||
{`https://user@example.com:8080/resource/`, `https://user@example.com:8080/resource/`},
|
||||
{`https://user@example.com:8080/resource/#fragment`, `https://user@example.com:8080/resource/`},
|
||||
{`https://user@example.com:8080/resource/?query=test#fragment`, `https://user@example.com:8080/resource/`},
|
||||
} {
|
||||
url, _ := url.Parse(x[0])
|
||||
if got, err := BaseURL(url); got != x[1] {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Errorf("%q: Expected %q but got %q.", x[0], x[1], got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue