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

Function TestDoGetRunOutput

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

Source from the content-addressed store, hash-verified

673}
674
675func TestDoGetRunOutput(t *testing.T) {
676 testCases := map[string]struct {
677 tr *respondingTransport
678 err error
679 finished bool
680 }{
681 "Incomplete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}`)}, nil, false},
682 "Complete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id": "65d2bb722be16277e3fa8e8c86d3afb7","items": [{"id": "0981fcaf99f2c1b4a46a22cedb417347","result": {"output": "PING bing.com (204.79.197.200): 56 data bytes\n64 bytes from 204.79.197.200: icmp_seq=0 ttl=119 time=40.348 ms\n64 bytes from 204.79.197.200: icmp_seq=1 ttl=119 time=40.198 ms\n64 bytes from 204.79.197.200: icmp_seq=2 ttl=119 time=40.241 ms\n--- bing.com ping statistics ---\n3 packets transmitted, 3 packets received, 0% packet loss\nround-trip min/avg/max/stddev = 40.198/40.262/40.348/0.063 ms\n","node": {"id": 5,"as_number": 23456,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "bing.com","finished": true}`)}, nil, true},
683 }
684 ctx := context.Background()
685 for name, tc := range testCases {
686 t.Run(name, func(t *testing.T) {
687 c, err := newTestClient(tc.tr)
688 if err != nil {
689 t.Fatalf("unexpected error %v", err)
690 }
691 got, err := c.Run.PingOutput(ctx, TestID("1234"))
692 if !cmpError(err, tc.err) {
693 t.Fatalf("expected error %v; got %v", tc.err, err)
694 }
695 if got.IsFinished() != tc.finished {
696 t.Fatalf("expected %v; got %v", tc.finished, got.IsFinished())
697 }
698 })
699 }
700}
701
702func cmpError(a, b error) bool {
703 return a == b || (a != nil && b != nil && a.Error() == b.Error())

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected