diff --git a/fedilogue/fedilogue_test.go b/fedilogue/fedilogue_test.go new file mode 100644 index 0000000..f31e96c --- /dev/null +++ b/fedilogue/fedilogue_test.go @@ -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() + +}