// Copyright (C) 2026 Dcntrlized // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package containers import "testing" func TestPeerPort(t *testing.T) { tests := []struct { name string labels map[string]string want string }{ {"nil labels fall back to default", nil, defaultPeerPort}, {"empty labels fall back to default", map[string]string{}, defaultPeerPort}, {"label present wins", map[string]string{"org.dcntrlized.peer_port": "9000"}, "9000"}, {"empty label value falls back to default", map[string]string{"org.dcntrlized.peer_port": ""}, defaultPeerPort}, {"unrelated labels fall back to default", map[string]string{"org.dcntrlized.port": "8080"}, defaultPeerPort}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := peerPort(tt.labels); got != tt.want { t.Fatalf("peerPort(%v) = %q, want %q", tt.labels, got, tt.want) } }) } }