fixed tests

part1, one test still failing
This commit is contained in:
Clemens 2024-03-28 09:36:08 +01:00
parent d624ebb712
commit 1ad7bdf983
11 changed files with 43 additions and 24 deletions

View file

@ -110,7 +110,7 @@ func Test_StarUnmarshalJSON(t *testing.T) {
}
}
func TestAcivityValidation(t *testing.T) {
func TestActivityValidation(t *testing.T) {
sut := new(ForgeLike)
sut.UnmarshalJSON([]byte(`{"type":"Like",
"actor":"https://repo.prod.meissa.de/api/activitypub/user-id/1",
@ -123,16 +123,16 @@ func TestAcivityValidation(t *testing.T) {
sut.UnmarshalJSON([]byte(`{"actor":"https://repo.prod.meissa.de/api/activitypub/user-id/1",
"object":"https://codeberg.org/api/activitypub/repository-id/1",
"startTime": "2014-12-31T23:00:00-08:00"}`))
if sut.Validate()[0] != "Field type may not be empty" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
if sut.Validate()[0] != "Field type should not be empty" {
t.Errorf("validation error expected but was: %v\n", sut.Validate()[0])
}
sut.UnmarshalJSON([]byte(`{"type":"bad-type",
"actor":"https://repo.prod.meissa.de/api/activitypub/user-id/1",
"object":"https://codeberg.org/api/activitypub/repository-id/1",
"startTime": "2014-12-31T23:00:00-08:00"}`))
if sut.Validate()[0] != "Value bad-type is not contained in allowed values [[Like]]" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
if sut.Validate()[0] != "Value bad-type is not contained in allowed values [Like]" {
t.Errorf("validation error expected but was: %v\n", sut.Validate()[0])
}
sut.UnmarshalJSON([]byte(`{"type":"Like",

View file

@ -66,7 +66,7 @@ func TestActorIdValidation(t *testing.T) {
sut.Host = "an.other.host"
sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/api/v1/activitypub/user-id/"
if sut.Validate()[0] != "Field userId may not be empty" {
if sut.Validate()[0] != "Field userId should not be empty" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
}
@ -78,8 +78,8 @@ func TestActorIdValidation(t *testing.T) {
sut.Host = "an.other.host"
sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/api/v1/activitypub/user-id/1?illegal=action"
if sut.Validate()[0] != "not all input: \"https://an.other.host/api/v1/activitypub/user-id/1?illegal=action\" was parsed: \"https://an.other.host/api/v1/activitypub/user-id/1\"" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
if sut.Validate()[0] != "not all input was parsed, \nUnvalidated Input:\"https://an.other.host/api/v1/activitypub/user-id/1?illegal=action\" \nParsed URI: \"https://an.other.host/api/v1/activitypub/user-id/1\"" {
t.Errorf("validation error expected but was: %v\n", sut.Validate()[0])
}
}
@ -104,8 +104,8 @@ func TestPersonIdValidation(t *testing.T) {
sut.Host = "an.other.host"
sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/api/v1/activitypub/user-id/1"
if sut.Validate()[0] != "Value forgejox is not contained in allowed values [[forgejo gitea]]" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
if sut.Validate()[0] != "Value forgejox is not contained in allowed values [forgejo gitea]" {
t.Errorf("validation error expected but was: %v\n", sut.Validate()[0])
}
}

View file

@ -52,7 +52,7 @@ func Test_NodeInfoWellKnownValidate(t *testing.T) {
}
sut = NodeInfoWellKnown{Href: "./federated-repo.prod.meissa.de/api/v1/nodeinfo"}
if _, err := validation.IsValid(sut); err.Error() != "Href has to be absolute\nValue is not contained in allowed values [[http https]]" {
if _, err := validation.IsValid(sut); err.Error() != "Href has to be absolute\nValue is not contained in allowed values [http https]" {
t.Errorf("validation error expected but was: %v\n", err)
}