Adding fedilogue_test.go with initial tests
This commit is contained in:
parent
e6e3cc1196
commit
c827375640
44
fedilogue/fedilogue_test.go
Normal file
44
fedilogue/fedilogue_test.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStatusReport_empty_run(t *testing.T) {
|
||||||
|
// Empty Instances run
|
||||||
|
StatusReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStatusReport_full_content(t *testing.T) {
|
||||||
|
defer func() {
|
||||||
|
runninginstances = map[string]RunningInstance{}
|
||||||
|
}()
|
||||||
|
runninginstances = make(map[string]RunningInstance)
|
||||||
|
|
||||||
|
identifier := 0
|
||||||
|
var endpoint string
|
||||||
|
|
||||||
|
test_instance_types := []string{"pleroma", "mastodon", "unknown", ""}
|
||||||
|
test_statuses := []int{NEW_INSTANCE, RUNNING, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, UNPROCESSABLE_ENTITY, TOOMANYREQUESTS, INTERNAL_ERROR, CLIENT_ISSUE, ONION_PROTOCOL, BAD_RESPONSE, BAD_NODEINFO, UNSUPPORTED_INSTANCE, STREAM_ENDED, KEEPALIVE}
|
||||||
|
|
||||||
|
for _, test_instance_type := range test_instance_types {
|
||||||
|
for _, test_status := range test_statuses {
|
||||||
|
a := RunningInstance{}
|
||||||
|
endpoint = "endpoint" + strconv.Itoa(identifier) + ".test.com"
|
||||||
|
a.client = BuildClient(endpoint)
|
||||||
|
a.Status = test_status
|
||||||
|
a.recentactivities = newUniqueFifo(10)
|
||||||
|
a.recentactors = newUniqueFifo(10)
|
||||||
|
a.Software = test_instance_type
|
||||||
|
a.Version = "0." + strconv.Itoa(identifier)
|
||||||
|
a.LastRun = time.Now().Format(time.RFC3339)
|
||||||
|
runninginstances[endpoint] = a
|
||||||
|
identifier = identifier + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusReport()
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user