Skip to content

Commit 3a6a818

Browse files
authored
Merge pull request #19 from OrangeBao/main
feat: add unit test for printer
2 parents 9962047 + 681d152 commit 3a6a818

File tree

3 files changed

+1838
-3
lines changed

3 files changed

+1838
-3
lines changed

pkg/command/share/printer.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package share
22

33
import (
44
"fmt"
5+
"io"
56
"os"
67
"strconv"
78

@@ -19,13 +20,16 @@ type PrintCheckData struct {
1920
}
2021

2122
func PrintResult(resultData []*PrintCheckData) {
22-
table := tablewriter.NewWriter(os.Stdout)
23+
PrintResultWithWriter(resultData, os.Stdout)
24+
}
25+
func PrintResultWithWriter(resultData []*PrintCheckData, writer io.Writer) {
26+
table := tablewriter.NewWriter(writer)
2327
table.SetHeader([]string{"S/N", "SRC_NODE_NAME", "DST_NODE_NAME", "TARGETP", "RESULT"})
2428

25-
tableException := tablewriter.NewWriter(os.Stdout)
29+
tableException := tablewriter.NewWriter(writer)
2630
tableException.SetHeader([]string{"S/N", "SRC_NODE_NAME", "DST_NODE_NAME", "TARGET", "RESULT", "LOG"})
2731

28-
tableFailed := tablewriter.NewWriter(os.Stdout)
32+
tableFailed := tablewriter.NewWriter(writer)
2933
tableFailed.SetHeader([]string{"S/N", "SRC_NODE_NAME", "DST_NODE_NAME", "TARGET", "RESULT", "LOG"})
3034

3135
resumeData := []*PrintCheckData{}

0 commit comments

Comments
 (0)