Use assert for test (#3201)

instead of `if`s
This commit is contained in:
qwerty287
2024-01-14 19:33:58 +01:00
committed by GitHub
parent b9f6f3f9fb
commit 001b5639a6
34 changed files with 417 additions and 1140 deletions

View File

@@ -17,16 +17,13 @@ package common_test
import (
"testing"
"github.com/stretchr/testify/assert"
"go.woodpecker-ci.org/woodpecker/v2/server/forge/common"
)
func Test_Netrc(t *testing.T) {
host, err := common.ExtractHostFromCloneURL("https://git.example.com/foo/bar.git")
if err != nil {
t.Fatal(err)
}
if host != "git.example.com" {
t.Errorf("Expected host to be git.example.com, got %s", host)
}
assert.NoError(t, err)
assert.Equal(t, "git.example.com", host)
}

View File

@@ -30,11 +30,8 @@ import (
"go.woodpecker-ci.org/woodpecker/v2/server/model"
)
func load(t *testing.T, config string) *GitLab {
_url, err := url.Parse(config)
if err != nil {
t.FailNow()
}
func load(config string) *GitLab {
_url, _ := url.Parse(config)
params := _url.Query()
_url.RawQuery = ""
@@ -58,7 +55,7 @@ func Test_GitLab(t *testing.T) {
env := server.URL + "?client_id=test&client_secret=test"
client := load(t, env)
client := load(env)
user := model.User{
Login: "test_user",