Refactor ipmi tests as table-driven tests

Also prefix each sensor line.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-11-07 21:41:54 -07:00
parent 2e2a7d7de3
commit 141bcd8d40
8 changed files with 182 additions and 95 deletions

View File

@@ -3,6 +3,7 @@ package sensors
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/batch"
@@ -75,12 +76,16 @@ func CobraRunE(vars *variables) func(cmd *cobra.Command, args []string) (err err
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s", result.Ipaddr, out)
for _, line := range strings.Split(out, "\n") {
wwlog.Error("%s: %s", result.Ipaddr, line)
}
returnErr = err
continue
}
wwlog.Info("%s:\n%s\n", result.Ipaddr, out)
for _, line := range strings.Split(out, "\n") {
wwlog.Info("%s: %s", result.Ipaddr, line)
}
}
return returnErr