Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

737 B
Raw Blame
package unifiedresources

import "testing"

func TestResourcePolicyRedactedTextPreservesWhitespace(t *testing.T) {
	resource := Resource{Name: "private-host", Policy: &ResourcePolicy{Routing: ResourceRoutingPolicy{Redact: []ResourceRedactionHint{ResourceRedactionHostname}}}}
	for _, value := range []string{" ", "\n\n", " Summary ", "\n private-host \n"} {
		want := value
		if value == "\n private-host \n" {
			want = "\n " + ResourcePolicyRedactedLabel + " \n"
		}
		if got := ResourcePolicyRedactedText(value, resource); got != want {
			t.Errorf("redact(%q) = %q, want %q", value, got, want)
		}
		if got := ResourcePolicyRedactedText(value, Resource{}); got != value {
			t.Errorf("without policy: %q != %q", got, value)
		}
	}
}