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.

1.1 KB
Raw Blame
package edition

import "testing"

func TestDefaultsToCommunity(t *testing.T) {
	// A fresh process (no SetEdition call) must read as community so the
	// public community binary is never treated as Pro.
	if got := Current(); got != Community {
		t.Fatalf("Current() default = %q, want %q", got, Community)
	}
	if IsPro() {
		t.Fatal("IsPro() default = true, want false")
	}
}

func TestSetEditionPro(t *testing.T) {
	t.Cleanup(func() { SetEdition(Community) })

	SetEdition(Pro)
	if got := Current(); got != Pro {
		t.Fatalf("Current() after SetEdition(Pro) = %q, want %q", got, Pro)
	}
	if !IsPro() {
		t.Fatal("IsPro() after SetEdition(Pro) = false, want true")
	}
}

func TestSetEditionNormalizesUnknownToCommunity(t *testing.T) {
	t.Cleanup(func() { SetEdition(Community) })

	for _, name := range []string{"", "enterprise", "PRO ", "Community", "bogus"} {
		SetEdition(name)
		got := Current()
		want := Community
		if name == "PRO " {
			want = Pro // trimmed + case-insensitive match
		}
		if got != want {
			t.Fatalf("Current() after SetEdition(%q) = %q, want %q", name, got, want)
		}
	}
}