Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-29 05:06:11 +01:00
This commit is contained in:
Michael Jerger 2024-01-13 16:22:49 +01:00
parent ca5eaa8c6b
commit 9a9ac33766
3 changed files with 6 additions and 6 deletions

View file

@ -178,7 +178,8 @@ func Test_PersonUnmarshalJSON(t *testing.T) {
PreferredUsername: ap.NaturalLanguageValues{ PreferredUsername: ap.NaturalLanguageValues{
ap.LangRefValue{Ref: "en", Value: []byte("MaxMuster")}, ap.LangRefValue{Ref: "en", Value: []byte("MaxMuster")},
}, },
}} },
}
sut := new(ForgePerson) sut := new(ForgePerson)
err := sut.UnmarshalJSON([]byte(`{"type":"Person","preferredUsername":"MaxMuster"}`)) err := sut.UnmarshalJSON([]byte(`{"type":"Person","preferredUsername":"MaxMuster"}`))
if err != nil { if err != nil {

View file

@ -62,19 +62,19 @@ func (node NodeInfoWellKnown) Validate() []string {
var result []string var result []string
result = append(result, validation.ValidateNotEmpty(node.Href, "Href")...) result = append(result, validation.ValidateNotEmpty(node.Href, "Href")...)
parsedUrl, err := url.Parse(node.Href) parsedURL, err := url.Parse(node.Href)
if err != nil { if err != nil {
result = append(result, err.Error()) result = append(result, err.Error())
return result return result
} }
if parsedUrl.Host == "" { if parsedURL.Host == "" {
result = append(result, "Href has to be absolute") result = append(result, "Href has to be absolute")
} }
result = append(result, validation.ValidateOneOf(parsedUrl.Scheme, []any{"http", "https"})...) result = append(result, validation.ValidateOneOf(parsedURL.Scheme, []any{"http", "https"})...)
if parsedUrl.RawQuery != "" { if parsedURL.RawQuery != "" {
result = append(result, "Href may not contain query") result = append(result, "Href may not contain query")
} }

View file

@ -29,7 +29,6 @@ func Test_ValidateNotEmpty_ForTimestamp(t *testing.T) {
if res := ValidateNotEmpty(sut, "dummyField"); len(res) > 0 { if res := ValidateNotEmpty(sut, "dummyField"); len(res) > 0 {
t.Errorf("sut should be valid but was %q", res) t.Errorf("sut should be valid but was %q", res)
} }
} }
func Test_ValidateMaxLen(t *testing.T) { func Test_ValidateMaxLen(t *testing.T) {