Skip to content

Commit

Permalink
fix check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumeet Rai committed Nov 14, 2024
1 parent 3cd8b3f commit f351ff9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/internal/tengoutil/secure_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func extractHeaders(args []tengo.Object) (map[string]string, error) {
for key, value := range headerMap.Value {
strValue, valueOk := tengo.ToString(value)
if !valueOk {
return nil, fmt.Errorf("header value for key '%s' must be a string", key)
return nil, fmt.Errorf("header value for key '%s' must be a string, got %T", key, value)
}
headers[key] = strValue
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/internal/tengoutil/secure_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ func TestNewSecureScript(t *testing.T) {

_, err = s.Run()
assert.Error(t, err)
assert.Contains(t, err.Error(), "expected argument 1 (URL) to be a string")
assert.Contains(t, err.Error(), "unsupported protocol scheme")
})

t.Run("HTTP GET with invalid header value type", func(t *testing.T) {
s, err := NewSecureScript(([]byte)(heredoc.Doc(`
s, err := NewSecureScript([]byte(`
http := import("http")
headers := { "User-Agent": 12345 }
http.get("http://example.com", headers)
`)), nil)
`), nil)
assert.NoError(t, err)

_, err = s.Compile()
assert.NoError(t, err)

_, err = s.Run()
assert.Error(t, err)
assert.Contains(t, err.Error(), "header value for key 'User-Agent' must be a string")
assert.Contains(t, err.Error(), "header value for key 'User-Agent' must be a string, got int")
})

t.Run("HTTP GET with timeout", func(t *testing.T) {
Expand Down

0 comments on commit f351ff9

Please sign in to comment.