enhance test & fix reviews
This commit is contained in:
parent
33648f2a4c
commit
fc38e56373
12 changed files with 101 additions and 20 deletions
|
@ -129,7 +129,7 @@ func (c *Client) Post(b []byte, to string) (resp *http.Response, err error) {
|
|||
}
|
||||
|
||||
// Create an http GET request with forgejo/gitea specific headers
|
||||
func (c *Client) Get(to string) (resp *http.Response, err error) { // ToDo: we might not need the b parameter
|
||||
func (c *Client) Get(to string) (resp *http.Response, err error) {
|
||||
var req *http.Request
|
||||
emptyBody := []byte{0}
|
||||
if req, err = c.NewRequest(http.MethodGet, emptyBody, to); err != nil {
|
||||
|
|
|
@ -32,8 +32,8 @@ func NewActorID(uri string) (ActorID, error) {
|
|||
return ActorID{}, err
|
||||
}
|
||||
|
||||
if valid, outcome := validation.IsValid(result); !valid {
|
||||
return ActorID{}, outcome
|
||||
if valid, err := validation.IsValid(result); !valid {
|
||||
return ActorID{}, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
@ -83,8 +83,8 @@ func NewPersonID(uri, source string) (PersonID, error) {
|
|||
|
||||
// validate Person specific path
|
||||
personID := PersonID{result}
|
||||
if valid, outcome := validation.IsValid(personID); !valid {
|
||||
return PersonID{}, outcome
|
||||
if valid, err := validation.IsValid(personID); !valid {
|
||||
return PersonID{}, err
|
||||
}
|
||||
|
||||
return personID, nil
|
||||
|
|
|
@ -92,7 +92,9 @@ func TestPersonIdValidation(t *testing.T) {
|
|||
sut.Host = "an.other.host"
|
||||
sut.Port = ""
|
||||
sut.UnvalidatedInput = "https://an.other.host/path/1"
|
||||
if _, err := validation.IsValid(sut); err.Error() != "path: \"path\" has to be a person specific api path" {
|
||||
|
||||
_, err := validation.IsValid(sut)
|
||||
if validation.IsErrNotValid(err) && strings.Contains(err.Error(), "path: \"path\" has to be a person specific api path\n") {
|
||||
t.Errorf("validation error expected but was: %v\n", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue