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

Function TestServiceRunWithContextError

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

Source from the content-addressed store, hash-verified

411}
412
413func TestServiceRunWithContextError(t *testing.T) {
414 bak := testOracle.Code
415 msg := "error while running oracle 1: nope"
416 testOracle.Code = "function findReasonsToLive(){ ctx.Error('nope'); }"
417 defer func() {
418 testOracle.Code = bak
419 }()
420
421 setup(t, true, true)
422 defer teardown(t)
423
424 if svc, err := New(testFolder, "", ""); err != nil {
425 t.Fatal(err)
426 } else if resp, err := svc.Run(context.TODO(), &testCall); err != nil {
427 t.Fatal(err)
428 } else if resp == nil {
429 t.Fatal("expected error response")
430 } else if resp.Success {
431 t.Fatal("expected error response")
432 } else if resp.Msg != msg {
433 t.Fatalf("unexpected response message: %s", resp.Msg)
434 } else if resp.Data != nil {
435 t.Fatalf("unexpected response data: %v", resp.Data)
436 }
437}

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