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.

828 B
Raw Blame
package models

import (
	"encoding/json"
	"strings"
	"testing"
)

func TestNodeUnmarshalCanonicalLinkedAgentID(t *testing.T) {
	var node Node
	if err := json.Unmarshal([]byte(`{"id":"node-1","linkedAgentId":"agent-canonical"}`), &node); err != nil {
		t.Fatalf("unmarshal failed: %v", err)
	}
	if node.LinkedAgentID != "agent-canonical" {
		t.Fatalf("LinkedAgentID = %q, want %q", node.LinkedAgentID, "agent-canonical")
	}
}

func TestNodeMarshalUsesCanonicalLinkedAgentID(t *testing.T) {
	node := Node{ID: "node-1", LinkedAgentID: "agent-canonical"}
	encoded, err := json.Marshal(node)
	if err != nil {
		t.Fatalf("marshal failed: %v", err)
	}
	serialized := string(encoded)
	if !strings.Contains(serialized, `"linkedAgentId":"agent-canonical"`) {
		t.Fatalf("expected canonical linkedAgentId in output: %s", serialized)
	}
}