fix gpu name issue introduced in previous commit

This commit is contained in:
henrygd
2025-06-27 18:00:47 -04:00
parent 4395520a28
commit 1627c41f84
2 changed files with 11 additions and 1 deletions

View File

@@ -243,7 +243,7 @@ func (gm *GPUManager) GetCurrentData() map[string]system.GPUData {
// copy / reset the data
gpuData := make(map[string]system.GPUData, len(gm.GpuDataMap))
for id, gpu := range gm.GpuDataMap {
var gpuAvg system.GPUData
gpuAvg := *gpu
gpuAvg.Temperature = twoDecimals(gpu.Temperature)
gpuAvg.MemoryUsed = twoDecimals(gpu.MemoryUsed)

View File

@@ -352,6 +352,15 @@ func TestGetCurrentData(t *testing.T) {
Power: 60,
Count: 1,
},
"2": {
Name: "GPU 2",
Temperature: 70,
MemoryUsed: 4096,
MemoryTotal: 8192,
Usage: 200,
Power: 400,
Count: 1,
},
},
}
@@ -360,6 +369,7 @@ func TestGetCurrentData(t *testing.T) {
// Verify name disambiguation
assert.Equal(t, "GPU1 0", result["0"].Name)
assert.Equal(t, "GPU1 1", result["1"].Name)
assert.Equal(t, "GPU 2", result["2"].Name)
// Check averaged values in the result
assert.InDelta(t, 50.0, result["0"].Usage, 0.01)