46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"gitlab.com/khanzf/fedilogue/shared"
|
|
"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 = shared.NewUniqueFifo(10)
|
|
a.recentactors = shared.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()
|
|
|
|
}
|