mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-11 04:11:18 +01:00
Update tests
This commit is contained in:
parent
25d34e0c14
commit
6ad52a6d67
1 changed files with 28 additions and 10 deletions
|
@ -19,6 +19,15 @@ var emptyMockStar *forgefed.Star = &forgefed.Star{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var invalidMockStar *forgefed.Star = &forgefed.Star{
|
||||||
|
Source: "",
|
||||||
|
Activity: ap.Activity{
|
||||||
|
Actor: ap.IRI(""),
|
||||||
|
Type: "Star",
|
||||||
|
Object: ap.IRI("https://example.com/"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var mockStar *forgefed.Star = &forgefed.Star{
|
var mockStar *forgefed.Star = &forgefed.Star{
|
||||||
Source: "forgejo",
|
Source: "forgejo",
|
||||||
Activity: ap.Activity{
|
Activity: ap.Activity{
|
||||||
|
@ -28,19 +37,28 @@ var mockStar *forgefed.Star = &forgefed.Star{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestActorParserEmpty(t *testing.T) {
|
func TestValidateAndParseIRIEmpty(t *testing.T) {
|
||||||
item := ""
|
item := emptyMockStar.Object.GetLink().String()
|
||||||
want := ActorID{}
|
|
||||||
|
|
||||||
got, _ := ParseActorID(item, "forgejo")
|
_, err := ValidateAndParseIRI(item)
|
||||||
|
|
||||||
if got != want {
|
if err == nil {
|
||||||
t.Errorf("ParseActorID returned non empty actor id for empty input.")
|
t.Errorf("ValidateAndParseIRI returned no error for empty input.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateAndParseIRINoPath(t *testing.T) {
|
||||||
|
item := emptyMockStar.Object.GetLink().String()
|
||||||
|
|
||||||
|
_, err := ValidateAndParseIRI(item)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("ValidateAndParseIRI returned no error for empty path.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestActorParserValid(t *testing.T) {
|
func TestActorParserValid(t *testing.T) {
|
||||||
item := mockStar.Actor.GetID().String()
|
item, _ := ValidateAndParseIRI(mockStar.Actor.GetID().String())
|
||||||
want := ActorID{
|
want := ActorID{
|
||||||
userId: "1",
|
userId: "1",
|
||||||
source: "forgejo",
|
source: "forgejo",
|
||||||
|
@ -50,7 +68,7 @@ func TestActorParserValid(t *testing.T) {
|
||||||
port: "",
|
port: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
got, _ := ParseActorID(item, "forgejo")
|
got := ParseActorID(item, "forgejo")
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("\nParseActorID did not return want: %v\n but %v", want, got)
|
t.Errorf("\nParseActorID did not return want: %v\n but %v", want, got)
|
||||||
|
@ -73,9 +91,9 @@ func TestValidateValid(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateInvalid(t *testing.T) {
|
func TestValidateInvalid(t *testing.T) {
|
||||||
item := emptyMockStar.Actor.GetID().String()
|
item, _ := ValidateAndParseIRI("https://example.org/some-path/to/nowhere/")
|
||||||
|
|
||||||
actor, _ := ParseActorID(item, "forgejo")
|
actor := ParseActorID(item, "forgejo")
|
||||||
|
|
||||||
if valid, _ := actor.IsValid(); valid {
|
if valid, _ := actor.IsValid(); valid {
|
||||||
t.Errorf("Actor was valid with invalid input.")
|
t.Errorf("Actor was valid with invalid input.")
|
||||||
|
|
Loading…
Reference in a new issue