Split test according to actor.go

This commit is contained in:
erik 2023-12-21 15:01:49 +01:00 committed by Michael Jerger
parent 48cfb521d1
commit 1dd3084f66

View file

@ -53,8 +53,8 @@ func TestNewRepositoryId(t *testing.T) {
}
}
func TestPersonIdValidation(t *testing.T) {
sut := PersonId{}
func TestActorIdValidation(t *testing.T) {
sut := ActorId{}
sut.Source = "forgejo"
sut.Schema = "https"
sut.Path = "api/v1/activitypub/user-id"
@ -65,7 +65,7 @@ func TestPersonIdValidation(t *testing.T) {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
}
sut = PersonId{}
sut = ActorId{}
sut.Id = "1"
sut.Source = "forgejox"
sut.Schema = "https"
@ -77,19 +77,7 @@ func TestPersonIdValidation(t *testing.T) {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
}
sut = PersonId{}
sut.Id = "1"
sut.Source = "forgejo"
sut.Schema = "https"
sut.Path = "path"
sut.Host = "an.other.host"
sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/path/1"
if sut.Validate()[0] != "path: \"path\" has to be a api path" {
t.Errorf("validation error expected but was: %v\n", sut.Validate())
}
sut = PersonId{}
sut = ActorId{}
sut.Id = "1"
sut.Source = "forgejo"
sut.Schema = "https"
@ -102,6 +90,20 @@ func TestPersonIdValidation(t *testing.T) {
}
}
func TestPersonIdValidation(t *testing.T) {
sut := PersonId{}
sut.Id = "1"
sut.Source = "forgejo"
sut.Schema = "https"
sut.Path = "path"
sut.Host = "an.other.host"
sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/path/1"
if _, err := sut.IsValid(); err.Error() != "path: \"path\" has to be an api path" {
t.Errorf("validation error expected but was: %v\n", err)
}
}
func TestWebfingerId(t *testing.T) {
sut, _ := NewPersonId("https://codeberg.org/api/v1/activitypub/user-id/12345", "forgejo")
if sut.AsWebfinger() != "@12345@codeberg.org" {