Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/tools/builtin/fetch/expander_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"net/http"
"net/http/httptest"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -32,7 +33,12 @@ func TestNilExpander(t *testing.T) {
t.Parallel()
expander := New(WithExpander(tc.expander)).handler.expander
assert.Nil(t, expander.ExpandMap(t.Context(), nil))
assert.Panics(t, func() { expander.ExpandMap(t.Context(), map[string]string{}) })
t.Run("nonempty map", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("recovered hardware faults can corrupt memory on Windows: golang/go#81238")
}
assert.Panics(t, func() { expander.ExpandMap(t.Context(), map[string]string{}) })
})
})
}
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/tools/builtin/webhook/expander_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package webhook

import (
"context"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -54,8 +55,13 @@ func TestNilTemplateExpander(t *testing.T) {
tool.client = &fakeDoer{}
verdict, _, _ := tool.attempt(t.Context(), SendArgs{Message: "hello"})
assert.Equal(t, delivered, verdict)
assert.Panics(t, func() { tool.expander.ExpandMap(t.Context(), map[string]string{}) })
assert.Panics(t, func() { tool.expander.Expand(t.Context(), "${env.VALUE}", nil) })
t.Run("nil receiver panics", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("recovered hardware faults can corrupt memory on Windows: golang/go#81238")
}
assert.Panics(t, func() { tool.expander.ExpandMap(t.Context(), map[string]string{}) })
assert.Panics(t, func() { tool.expander.Expand(t.Context(), "${env.VALUE}", nil) })
})
})
}
}
Loading