@@ -22,7 +22,7 @@ func TestCommand_Execute(t *testing.T) {
2222
2323 assert .Nil (t , err )
2424 assert .True (t , cmd .Executed ())
25- assert . Equal (t , cmd .Stdout (), "hello \n " )
25+ assertEqualWithLineBreak (t , "hello" , cmd .Stdout ())
2626}
2727
2828func TestCommand_ExitCode (t * testing.T ) {
@@ -44,7 +44,7 @@ func TestCommand_WithEnvVariables(t *testing.T) {
4444
4545 _ = cmd .Execute ()
4646
47- assert . Equal (t , cmd .Stdout (), "hey \n " )
47+ assertEqualWithLineBreak (t , "hey" , cmd .Stdout ())
4848}
4949
5050func TestCommand_Executed (t * testing.T ) {
@@ -77,7 +77,7 @@ func TestCommand_AddEnvWithShellVariable(t *testing.T) {
7777 err := c .Execute ()
7878
7979 assert .Nil (t , err )
80- assert . Equal (t , "test from shell\n " , c .Stdout ())
80+ assertEqualWithLineBreak (t , "test from shell" , c .Stdout ())
8181}
8282
8383func TestCommand_AddMultipleEnvWithShellVariable (t * testing.T ) {
@@ -97,7 +97,7 @@ func TestCommand_AddMultipleEnvWithShellVariable(t *testing.T) {
9797 err := c .Execute ()
9898
9999 assert .Nil (t , err )
100- assert . Equal (t , "Hello world, I am Simon\n " , c .Stdout ())
100+ assertEqualWithLineBreak (t , "Hello world, I am Simon" , c .Stdout ())
101101}
102102
103103func getCommand () string {
@@ -149,5 +149,15 @@ func TestCommand_SetOptions(t *testing.T) {
149149
150150 assert .Nil (t , err )
151151 assert .Equal (t , time .Duration (1000000000 ), c .Timeout )
152- assert .Equal (t , "test\n " , writer .String ())
153- }
152+ assertEqualWithLineBreak (t , "test" , writer .String ())
153+ }
154+
155+ func assertEqualWithLineBreak (t * testing.T , expected string , actual string ) {
156+ if runtime .GOOS == "windows" {
157+ expected = expected + "\r \n "
158+ } else {
159+ expected = expected + "\n "
160+ }
161+
162+ assert .Equal (t , expected , actual )
163+ }
0 commit comments