mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 15:37:35 +00:00
added test cases for federationhost
This commit is contained in:
parent
8f42684599
commit
379b0234eb
|
@ -4,6 +4,7 @@
|
||||||
package forgefed
|
package forgefed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -22,13 +23,35 @@ func Test_FederationHostValidation(t *testing.T) {
|
||||||
t.Errorf("sut should be valid but was %q", err)
|
t.Errorf("sut should be valid but was %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sut = FederationHost{
|
||||||
|
HostFqdn: "",
|
||||||
|
NodeInfo: NodeInfo{
|
||||||
|
SoftwareName: "forgejo",
|
||||||
|
},
|
||||||
|
LatestActivity: time.Now(),
|
||||||
|
}
|
||||||
|
if res, _ := validation.IsValid(sut); res {
|
||||||
|
t.Errorf("sut should be invalid: HostFqdn empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
sut = FederationHost{
|
||||||
|
HostFqdn: strings.Repeat("fill", 64),
|
||||||
|
NodeInfo: NodeInfo{
|
||||||
|
SoftwareName: "forgejo",
|
||||||
|
},
|
||||||
|
LatestActivity: time.Now(),
|
||||||
|
}
|
||||||
|
if res, _ := validation.IsValid(sut); res {
|
||||||
|
t.Errorf("sut should be invalid: HostFqdn too long (len=256)")
|
||||||
|
}
|
||||||
|
|
||||||
sut = FederationHost{
|
sut = FederationHost{
|
||||||
HostFqdn: "host.do.main",
|
HostFqdn: "host.do.main",
|
||||||
NodeInfo: NodeInfo{},
|
NodeInfo: NodeInfo{},
|
||||||
LatestActivity: time.Now(),
|
LatestActivity: time.Now(),
|
||||||
}
|
}
|
||||||
if res, _ := validation.IsValid(sut); res {
|
if res, _ := validation.IsValid(sut); res {
|
||||||
t.Errorf("sut should be invalid")
|
t.Errorf("sut should be invalid: NodeInfo invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
sut = FederationHost{
|
sut = FederationHost{
|
||||||
|
|
Loading…
Reference in a new issue