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

Function TestDNSResolveOutput

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

Source from the content-addressed store, hash-verified

360}
361
362func TestDNSResolveOutput(t *testing.T) {
363 testCases := map[string]struct {
364 tr *respondingTransport
365 err error
366 finished bool
367 }{
368 "Incomplete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}`)}, nil, false},
369 "Complete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id": "66b78cfc643ea238e0fd8ab44f512657","items": [{"id": "ae3e8bcd0fbe77d6322b89371d87d96d","result": {"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","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},
370 }
371 ctx := context.Background()
372 for name, tc := range testCases {
373 t.Run(name, func(t *testing.T) {
374 c, err := newTestClient(tc.tr)
375 if err != nil {
376 t.Fatalf("unexpected error %v", err)
377 }
378 got, err := c.Run.DNSResolveOutput(ctx, TestID("1234"))
379 if !cmpError(err, tc.err) {
380 t.Fatalf("expected error %v; got %v", tc.err, err)
381 }
382 if got.IsFinished() != tc.finished {
383 t.Fatalf("expected %v; got %v", tc.finished, got.IsFinished())
384 }
385 })
386 }
387}
388
389func TestDNSTestResult_ResolveOutput(t *testing.T) {
390 testCases := map[string]struct {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected