2021-08-07 19:45:04 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
"time"
|
2022-01-01 02:26:39 +00:00
|
|
|
|
|
|
|
"gitlab.com/khanzf/fedilogue/shared"
|
2021-08-07 19:45:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStatusReport_empty_run(t *testing.T) {
|
|
|
|
// Empty Instances run
|
|
|
|
StatusReport()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStatusReport_full_content(t *testing.T) {
|
|
|
|
defer func() {
|
2022-01-01 02:26:39 +00:00
|
|
|
runninginstances = map[string]shared.RunningInstance{}
|
2021-08-07 19:45:04 +00:00
|
|
|
}()
|
2022-01-01 02:26:39 +00:00
|
|
|
runninginstances = make(map[string]shared.RunningInstance)
|
2021-08-07 19:45:04 +00:00
|
|
|
|
|
|
|
identifier := 0
|
|
|
|
var endpoint string
|
|
|
|
|
|
|
|
test_instance_types := []string{"pleroma", "mastodon", "unknown", ""}
|
2022-01-01 02:26:39 +00:00
|
|
|
test_statuses := []int{shared.NEW_INSTANCE, shared.RUNNING, shared.UNAUTHORIZED, shared.FORBIDDEN, shared.NOT_FOUND, shared.UNPROCESSABLE_ENTITY, shared.TOOMANYREQUESTS, shared.INTERNAL_ERROR, shared.CLIENT_ISSUE, shared.ONION_PROTOCOL, shared.BAD_RESPONSE, shared.BAD_NODEINFO, shared.UNSUPPORTED_INSTANCE, shared.STREAM_ENDED, shared.KEEPALIVE}
|
2021-08-07 19:45:04 +00:00
|
|
|
|
|
|
|
for _, test_instance_type := range test_instance_types {
|
|
|
|
for _, test_status := range test_statuses {
|
2022-01-01 02:26:39 +00:00
|
|
|
a := shared.RunningInstance{}
|
2021-08-07 19:45:04 +00:00
|
|
|
endpoint = "endpoint" + strconv.Itoa(identifier) + ".test.com"
|
2022-01-01 02:26:39 +00:00
|
|
|
a.Client = BuildClient(endpoint)
|
2021-08-07 19:45:04 +00:00
|
|
|
a.Status = test_status
|
2022-01-01 02:26:39 +00:00
|
|
|
a.Recentactivities = shared.NewUniqueFifo(10)
|
|
|
|
a.Recentactors = shared.NewUniqueFifo(10)
|
2021-08-07 19:45:04 +00:00
|
|
|
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()
|
|
|
|
|
|
|
|
}
|