Skip to content

Commit

Permalink
chore: fix ...
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed Dec 12, 2023
1 parent c6ba7ee commit 0fa374e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkg/skaffold/hooks/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ func TestRenderHooks(t *testing.T) {
{
HostHook: &latest.HostHook{
OS: []string{"windows"},
Command: []string{"cmd.exe", "/C", "echo pre-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
Command: []string{"pwsh", "-Command", "echo pre-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
},
},
},
PostHooks: []latest.PostRenderHookItem{
{
HostHook: &latest.PostRenderHostHook{
OS: []string{"windows"},
Command: []string{"cmd.exe", "/C", "echo post-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
Command: []string{"pwsh", "-Command", "echo post-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
},
},
},
Expand All @@ -127,15 +127,15 @@ func TestRenderHooks(t *testing.T) {
{
HostHook: &latest.HostHook{
OS: []string{"windows"},
Command: []string{"cmd.exe", "/C", "echo pre-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
Command: []string{"pwsh", "-Command", "echo pre-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
},
},
},
PostHooks: []latest.PostRenderHookItem{
{
HostHook: &latest.PostRenderHostHook{
OS: []string{"windows"},
Command: []string{"cmd.exe", "/C", "echo post-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
Command: []string{"pwsh", "-Command", "echo post-hook running with SKAFFOLD_KUBE_CONTEXT=%SKAFFOLD_KUBE_CONTEXT%,SKAFFOLD_NAMESPACES=%SKAFFOLD_NAMESPACES%"},
},
},
},
Expand All @@ -151,11 +151,19 @@ func TestRenderHooks(t *testing.T) {
preOutFile, err := os.CreateTemp("", "")
defer os.Remove(preOutFile.Name())
t.CheckNoError(err)
test.hooks.PreHooks[0].HostHook.Command[2] = test.hooks.PreHooks[0].HostHook.Command[2] + " > " + preOutFile.Name()
if test.requiresWindowsOS {
test.hooks.PreHooks[0].HostHook.Command[2] = test.hooks.PreHooks[0].HostHook.Command[2] + " | Set-Content -Path " + preOutFile.Name()
} else {
test.hooks.PreHooks[0].HostHook.Command[2] = test.hooks.PreHooks[0].HostHook.Command[2] + " > " + preOutFile.Name()
}
postOutFile, err := os.CreateTemp("", "")
defer os.Remove(postOutFile.Name())
t.CheckNoError(err)
test.hooks.PostHooks[0].HostHook.Command[2] = test.hooks.PostHooks[0].HostHook.Command[2] + " > " + postOutFile.Name()
if test.requiresWindowsOS {
test.hooks.PostHooks[0].HostHook.Command[2] = test.hooks.PostHooks[0].HostHook.Command[2] + " | Set-Content -Path " + postOutFile.Name()
} else {
test.hooks.PostHooks[0].HostHook.Command[2] = test.hooks.PostHooks[0].HostHook.Command[2] + " > " + postOutFile.Name()
}

namespaces := []string{"np1", "np2"}
opts := NewRenderEnvOpts(testKubeContext, namespaces)
Expand Down

0 comments on commit 0fa374e

Please sign in to comment.