MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / TestCurlOutput

Function TestCurlOutput

perfops/run_test.go:481–506  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

479}
480
481func TestCurlOutput(t *testing.T) {
482 testCases := map[string]struct {
483 tr *respondingTransport
484 err error
485 finished bool
486 }{
487 "Incomplete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}`)}, nil, false},
488 "Complete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id": "9b8253c07b53b2db82b05475f9895f4e","items": [{"id": "99e4a2c3d6c8c7e36681515a2d2978e5","result": {"output": "HTTP/1.1 301 Moved Permanently\nContent-length: 0\nLocation: https://github.com/\n\n","node": {"id": 218,"as_number": 23456,"latitude": 49.09803738740174,"longitude": 12.484245300292855,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Falkenstein","sub_region": "Western Europe"}}}],"requested": "github.com","finished": true}`)}, nil, true},
489 }
490 ctx := context.Background()
491 for name, tc := range testCases {
492 t.Run(name, func(t *testing.T) {
493 c, err := newTestClient(tc.tr)
494 if err != nil {
495 t.Fatalf("unexpected error %v", err)
496 }
497 got, err := c.Run.CurlOutput(ctx, TestID("1234"))
498 if !cmpError(err, tc.err) {
499 t.Fatalf("expected error %v; got %v", tc.err, err)
500 }
501 if got.IsFinished() != tc.finished {
502 t.Fatalf("expected %v; got %v", tc.finished, got.IsFinished())
503 }
504 })
505 }
506}
507
508func TestPerfOuput(t *testing.T) {
509 testCases := map[string]struct {

Callers

nothing calls this directly

Calls 6

dummyRespFunction · 0.85
newTestClientFunction · 0.85
TestIDTypeAlias · 0.85
CurlOutputMethod · 0.80
cmpErrorFunction · 0.70
IsFinishedMethod · 0.45

Tested by

no test coverage detected