github.com/mweagle/Sparta@v1.15.0/system/exec_test.go (about) 1 package system 2 3 import ( 4 "os/exec" 5 "runtime" 6 "testing" 7 8 "github.com/sirupsen/logrus" 9 ) 10 11 func TestRunCommand(t *testing.T) { 12 commandName := "" 13 switch runtime.GOOS { 14 case "windows": 15 commandName = "ipconfig" 16 default: 17 commandName = "date" 18 } 19 cmd := exec.Command(commandName) 20 logger := logrus.New() 21 runErr := RunOSCommand(cmd, logger) 22 if runErr != nil { 23 t.Fatalf("Failed to run command `%s` (OS: %s). Error: %s", 24 commandName, 25 runtime.GOOS, 26 runErr) 27 } 28 }