Fixed error
Build Docker image on push / docker (push) Successful in 23s

This commit is contained in:
2026-08-24 01:55:40 +02:00
parent e8e94c5da1
commit 9b076d4353
5 changed files with 98 additions and 18 deletions
+62
View File
@@ -3,6 +3,8 @@ package proxmox
import (
"encoding/json"
"testing"
"github.com/mitchellh/mapstructure"
)
func TestPveClusterStatusGetClusterModeNumeric(t *testing.T) {
@@ -112,3 +114,63 @@ func TestPveZfsPoolStatusUnmarshal(t *testing.T) {
t.Fatal("missing cache counters must stay absent instead of becoming zero metrics")
}
}
func TestPveSdnResourceGetName(t *testing.T) {
tests := []struct {
name string
resource PveSdnResource
want string
}{
{
name: "sdn resource",
resource: PveSdnResource{SDN: "localnetwork"},
want: "localnetwork",
},
{
name: "network resource",
resource: PveSdnResource{Network: "localnetwork", NetworkType: "zone"},
want: "localnetwork",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.resource.GetName(); got != tt.want {
t.Fatalf("GetName() = %v, want %v", got, tt.want)
}
})
}
}
func TestPveSdnResourceDecodeNetwork(t *testing.T) {
// Resource object as reported by PVE 9 for SDN entities.
obj := map[string]interface{}{
"id": "network/pve1/zone/localnetwork",
"type": "network",
"node": "pve1",
"status": "ok",
"network": "localnetwork",
"network-type": "zone",
}
var resource PveSdnResource
if err := mapstructure.Decode(obj, &resource); err != nil {
t.Fatalf("Decode() error = %v", err)
}
if err := mapstructure.Decode(obj, &resource.PveResource); err != nil {
t.Fatalf("Decode() error = %v", err)
}
if got, want := resource.GetName(), "localnetwork"; got != want {
t.Fatalf("GetName() = %v, want %v", got, want)
}
if got, want := resource.NetworkType, "zone"; got != want {
t.Fatalf("NetworkType = %v, want %v", got, want)
}
if got, want := resource.ID, "network/pve1/zone/localnetwork"; got != want {
t.Fatalf("ID = %v, want %v", got, want)
}
if got, want := resource.GetStatusNumeric(), float64(1); got != want {
t.Fatalf("GetStatusNumeric() = %v, want %v", got, want)
}
}