MCPcopy Create free account
hub / github.com/evilsocket/sum / TestServiceRunWithRuntimeError

Function TestServiceRunWithRuntimeError

service/service_test.go:388–411  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

386}
387
388func TestServiceRunWithRuntimeError(t *testing.T) {
389 bak := testOracle.Code
390 msg := "error while running oracle 1: ReferenceError: 'im_not_defined' is not defined"
391 testOracle.Code = "function test(){ return im_not_defined }"
392 defer func() {
393 testOracle.Code = bak
394 }()
395 setup(t, true, true)
396 defer teardown(t)
397
398 if svc, err := New(testFolder, "", ""); err != nil {
399 t.Fatal(err)
400 } else if resp, err := svc.Run(context.TODO(), &testCall); err != nil {
401 t.Fatal(err)
402 } else if resp == nil {
403 t.Fatal("expected error response")
404 } else if resp.Success {
405 t.Fatal("expected error response")
406 } else if resp.Msg != msg {
407 t.Fatalf("unexpected response message: %s", resp.Msg)
408 } else if resp.Data != nil {
409 t.Fatalf("unexpected response data: %v", resp.Data)
410 }
411}
412
413func TestServiceRunWithContextError(t *testing.T) {
414 bak := testOracle.Code

Callers

nothing calls this directly

Calls 4

setupFunction · 0.85
teardownFunction · 0.85
NewFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected