fedilogue/fedilogger/fedilogue_test.go

47 lines
1.4 KiB
Go
Raw Normal View History

package main
import (
"strconv"
"testing"
"time"
2022-01-01 02:26:39 +00:00
"gitlab.com/khanzf/fedilogue/shared"
)
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{}
}()
2022-01-01 02:26:39 +00:00
runninginstances = make(map[string]shared.RunningInstance)
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}
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{}
endpoint = "endpoint" + strconv.Itoa(identifier) + ".test.com"
2022-01-01 02:26:39 +00:00
a.Client = BuildClient(endpoint)
a.Status = test_status
2022-01-01 02:26:39 +00:00
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()
}