diff --git a/internal/api/backresthandler_test.go b/internal/api/backresthandler_test.go index d3044645..68398f54 100644 --- a/internal/api/backresthandler_test.go +++ b/internal/api/backresthandler_test.go @@ -248,16 +248,17 @@ func TestMultipleBackup(t *testing.T) { func TestHookExecution(t *testing.T) { t.Parallel() - - if runtime.GOOS == "windows" { - t.Skip("skipping test on windows") - } - dir := t.TempDir() - hookOutputBefore := path.Join(dir, "before.txt") hookOutputAfter := path.Join(dir, "after.txt") + commandBefore := fmt.Sprintf("echo before > %s", hookOutputBefore) + commandAfter := fmt.Sprintf("echo after > %s", hookOutputAfter) + if runtime.GOOS == "windows" { + commandBefore = fmt.Sprintf("echo \"before\" | Out-File -FilePath %q", hookOutputBefore) + commandAfter = fmt.Sprintf("echo \"after\" | Out-File -FilePath %q", hookOutputAfter) + } + sut := createSystemUnderTest(t, &config.MemoryStore{ Config: &v1.Config{ Modno: 1234, @@ -287,7 +288,7 @@ func TestHookExecution(t *testing.T) { }, Action: &v1.Hook_ActionCommand{ ActionCommand: &v1.Hook_Command{ - Command: "echo before > " + hookOutputBefore, + Command: commandBefore, }, }, }, @@ -297,7 +298,7 @@ func TestHookExecution(t *testing.T) { }, Action: &v1.Hook_ActionCommand{ ActionCommand: &v1.Hook_Command{ - Command: "echo after > " + hookOutputAfter, + Command: commandAfter, }, }, }, diff --git a/internal/hook/types/command.go b/internal/hook/types/command.go index bad96ade..19457649 100644 --- a/internal/hook/types/command.go +++ b/internal/hook/types/command.go @@ -34,7 +34,7 @@ func (commandHandler) Execute(ctx context.Context, h *v1.Hook, vars interface{}, // Parse out the shell to use if a #! prefix is present shell := []string{"sh"} if runtime.GOOS == "windows" { - shell = []string{"powershell", "-nologo", "-noprofile"} + shell = []string{"powershell", "-NoLogo", "-NoProfile", "-Command", "-"} } if len(command) > 2 && command[0:2] == "#!" {