Skip to content

Commit

Permalink
Merge pull request #150 from trheyi/main
Browse files Browse the repository at this point in the history
[change] Optimize script error message
  • Loading branch information
trheyi authored Sep 11, 2023
2 parents fda1663 + f1d56fe commit 60be0e3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions http/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,36 @@ func TestHTTPSend(t *testing.T) {
assert.NotNil(t, resp.Message)
}

func TestHTTPSendText(t *testing.T) {

shutdown, ready, host := processSetup()
go processStart(t, &host, shutdown, ready)
defer processStop(shutdown, ready)
<-ready

v := process.New("http.Send", "POST", fmt.Sprintf("%s/path?foo=bar", host),
"User Input Text",
map[string]string{"hello": "world"},
map[string]string{"Auth": "Test", "Content-Type": "text/plain"},
).Run()

resp, ok := v.(*Response)
if !ok {
t.Fatal(fmt.Errorf("response error %#v", v))
}
if resp.Status == 0 {
t.Fatal(resp.Message)
}

assert.Equal(t, 200, resp.Status)
res := any.Of(resp.Data).MapStr().Dot()
assert.Equal(t, "bar", res.Get("query.foo[0]"))
assert.Equal(t, "world", res.Get("query.hello[0]"))
assert.Equal(t, "Test", res.Get("headers.Auth[0]"))
assert.Equal(t, `User Input Text`, res.Get("payload"))

}

func TestHTTPStream(t *testing.T) {

shutdown, ready, host := processSetup()
Expand Down
4 changes: 2 additions & 2 deletions runtime/v8/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func processScripts(process *process.Process) interface{} {

ctx, err := script.NewContext(process.Sid, process.Global)
if err != nil {
message := fmt.Sprintf("scripts.%s failed to create context. %s", process.ID, err.Error())
message := fmt.Sprintf("scripts.%s failed to create context. %+v", process.ID, err.Error())
log.Error("[V8] process error. %s", message)
exception.New(message, 500).Throw()
return nil
Expand All @@ -50,7 +50,7 @@ func processStudio(process *process.Process) interface{} {

ctx, err := script.NewContext(process.Sid, process.Global)
if err != nil {
message := fmt.Sprintf("studio.%s failed to create context. %s", process.ID, err.Error())
message := fmt.Sprintf("studio.%s failed to create context. %+v", process.ID, err.Error())
log.Error("[V8] process error. %s", message)
exception.New(message, 500).Throw()
return nil
Expand Down

0 comments on commit 60be0e3

Please sign in to comment.