Skip to content

Commit 34e3572

Browse files
fix: tests
*fixes broken intellinet tests *updates all tests to work with the new implementation of the pdu interface Signed-off-by: jonas loeffelholz <jonas.loeffelholz@9elements.com>
1 parent ebd9eda commit 34e3572

3 files changed

Lines changed: 12 additions & 24 deletions

File tree

pkg/module/pdu/gude_test.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 Blindspot Software
1+
// Copyright 2026 Blindspot Software
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -340,13 +340,10 @@ func TestGudeParseOutletStatus(t *testing.T) {
340340

341341
for _, tt := range tests {
342342
t.Run(tt.name, func(t *testing.T) {
343-
g := &gude{
344-
pdu: &PDU{
345-
Outlet: tt.outlet,
346-
},
347-
}
343+
g := gude{}
344+
p := &PDU{Outlet: tt.outlet}
348345

349-
result, err := g.parseOutletStatus([]byte(tt.jsonBody))
346+
result, err := g.parseOutletStatus(p, []byte(tt.jsonBody))
350347

351348
if tt.err {
352349
if err == nil {
@@ -397,13 +394,10 @@ func TestGudeGetOutletAPIParameter(t *testing.T) {
397394

398395
for _, tt := range tests {
399396
t.Run(tt.name, func(t *testing.T) {
400-
g := &gude{
401-
pdu: &PDU{
402-
Outlet: tt.outlet,
403-
},
404-
}
397+
g := gude{}
398+
p := &PDU{Outlet: tt.outlet}
405399

406-
result := g.getOutletAPIParameter()
400+
result := g.getOutletAPIParameter(p)
407401
if result != tt.expected {
408402
t.Errorf("getOutletAPIParameter() = %v, expected %v", result, tt.expected)
409403
}

pkg/module/pdu/intellinet_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,10 @@ func TestParseOutletStatus(t *testing.T) {
116116

117117
for _, tt := range tests {
118118
t.Run(tt.name, func(t *testing.T) {
119+
i := intellinet{}
120+
p := &PDU{Outlet: tt.outlet}
119121

120-
i := &intellinet{
121-
pdu: &PDU{
122-
Outlet: tt.outlet,
123-
},
124-
}
125-
126-
result, err := i.parseOutletStatus([]byte(tt.xmlBody))
122+
result, err := i.parseOutletStatus(p, []byte(tt.xmlBody))
127123

128124
if tt.err {
129125
if err == nil {

pkg/module/pdu/pdu.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025-2026 Blindspot Software
1+
// Copyright 2025 Blindspot Software
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -55,7 +55,7 @@ type pdu interface {
5555
}
5656

5757
// PDU is a module that provides basic power management functions for a PDU (Power Distribution Unit).
58-
// NOTE: This implementation currently supports only Intellinet ATM PDUs.
58+
// NOTE: This implementation currently supports Intellinet style (e.g. Intellinet 163682, LogiLink PDU8P01) and Gude PDUs.
5959
type PDU struct {
6060
Host string // Host is the address of the PDU
6161
User string // User is used for authentication, if supported by the PDU
@@ -97,8 +97,6 @@ const (
9797
off = "off"
9898
toggle = "toggle"
9999
status = "status"
100-
intellinetPDU = "intellinet"
101-
gudePDU = "gude"
102100
)
103101

104102
func (p *PDU) Init() error {

0 commit comments

Comments
 (0)