Skip to content

Commit e3e01df

Browse files
Forgor to lint
1 parent 3453648 commit e3e01df

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ linters:
1010
- dupl
1111
- errcheck
1212
- ginkgolinter
13-
- goconst
1413
- govet
1514
- ineffassign
1615
- lll

internal/libvirt/capabilities/client_test.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package capabilities
1919

2020
import (
2121
"encoding/xml"
22-
"os"
2322
"testing"
2423

2524
"k8s.io/apimachinery/pkg/api/resource"
@@ -40,18 +39,9 @@ func TestNewClient(t *testing.T) {
4039
}
4140

4241
func TestNewClientWithCustomSocket(t *testing.T) {
43-
// Set custom socket path
44-
originalSocket := os.Getenv("LIBVIRT_SOCKET")
45-
defer func() {
46-
if originalSocket != "" {
47-
os.Setenv("LIBVIRT_SOCKET", originalSocket)
48-
} else {
49-
os.Unsetenv("LIBVIRT_SOCKET")
50-
}
51-
}()
52-
42+
// Set custom socket path using t.Setenv for automatic cleanup
5343
customSocket := "/custom/libvirt-sock"
54-
os.Setenv("LIBVIRT_SOCKET", customSocket)
44+
t.Setenv("LIBVIRT_SOCKET", customSocket)
5545

5646
client := NewClient()
5747
if client == nil {
@@ -386,10 +376,9 @@ func TestConvertWithRealExampleData(t *testing.T) {
386376

387377
// Test helper function to create a mock capabilities structure
388378
func createMockCapabilities(arch string, cells []mockCell) Capabilities {
389-
var capabilitiesCells []CapabilitiesHostTopologyCell
390-
391-
for _, cell := range cells {
392-
capabilitiesCells = append(capabilitiesCells, CapabilitiesHostTopologyCell{
379+
capabilitiesCells := make([]CapabilitiesHostTopologyCell, 0, len(cells))
380+
for i, cell := range cells {
381+
capabilitiesCells[i] = CapabilitiesHostTopologyCell{
393382
ID: cell.ID,
394383
Memory: CapabilitiesHostTopologyCellMemory{
395384
Unit: cell.MemoryUnit,
@@ -398,7 +387,7 @@ func createMockCapabilities(arch string, cells []mockCell) Capabilities {
398387
CPUs: CapabilitiesHostTopologyCellCPUs{
399388
Num: cell.CPUCount,
400389
},
401-
})
390+
}
402391
}
403392

404393
return Capabilities{

0 commit comments

Comments
 (0)