mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 08:31:27 -05:00
Split test according to actor.go
This commit is contained in:
parent
48cfb521d1
commit
1dd3084f66
1 changed files with 18 additions and 16 deletions
|
@ -53,8 +53,8 @@ func TestNewRepositoryId(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPersonIdValidation(t *testing.T) {
|
func TestActorIdValidation(t *testing.T) {
|
||||||
sut := PersonId{}
|
sut := ActorId{}
|
||||||
sut.Source = "forgejo"
|
sut.Source = "forgejo"
|
||||||
sut.Schema = "https"
|
sut.Schema = "https"
|
||||||
sut.Path = "api/v1/activitypub/user-id"
|
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())
|
t.Errorf("validation error expected but was: %v\n", sut.Validate())
|
||||||
}
|
}
|
||||||
|
|
||||||
sut = PersonId{}
|
sut = ActorId{}
|
||||||
sut.Id = "1"
|
sut.Id = "1"
|
||||||
sut.Source = "forgejox"
|
sut.Source = "forgejox"
|
||||||
sut.Schema = "https"
|
sut.Schema = "https"
|
||||||
|
@ -77,19 +77,7 @@ func TestPersonIdValidation(t *testing.T) {
|
||||||
t.Errorf("validation error expected but was: %v\n", sut.Validate())
|
t.Errorf("validation error expected but was: %v\n", sut.Validate())
|
||||||
}
|
}
|
||||||
|
|
||||||
sut = PersonId{}
|
sut = ActorId{}
|
||||||
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.Id = "1"
|
sut.Id = "1"
|
||||||
sut.Source = "forgejo"
|
sut.Source = "forgejo"
|
||||||
sut.Schema = "https"
|
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) {
|
func TestWebfingerId(t *testing.T) {
|
||||||
sut, _ := NewPersonId("https://codeberg.org/api/v1/activitypub/user-id/12345", "forgejo")
|
sut, _ := NewPersonId("https://codeberg.org/api/v1/activitypub/user-id/12345", "forgejo")
|
||||||
if sut.AsWebfinger() != "@12345@codeberg.org" {
|
if sut.AsWebfinger() != "@12345@codeberg.org" {
|
||||||
|
|
Loading…
Reference in a new issue