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

Function TestDNSPerfOutput

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

Source from the content-addressed store, hash-verified

275}
276
277func TestDNSPerfOutput(t *testing.T) {
278 testCases := map[string]struct {
279 tr *respondingTransport
280 err error
281 finished bool
282 }{
283 "Incomplete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}`)}, nil, false},
284 "Complete": {&respondingTransport{resp: dummyResp(200, "GET", `{"id": "6938330049d86df74bb2d0c76f3479de","items": [{"id": "68d10bfb6a9c7f9c519d17df83bc389e","result": {"dnsServer": "8.8.8.8","output": "35","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": "google.com","finished": true}`)}, nil, true},
285 }
286 ctx := context.Background()
287 for name, tc := range testCases {
288 t.Run(name, func(t *testing.T) {
289 c, err := newTestClient(tc.tr)
290 if err != nil {
291 t.Fatalf("unexpected error %v", err)
292 }
293 got, err := c.Run.DNSPerfOutput(ctx, TestID("1234"))
294 if !cmpError(err, tc.err) {
295 t.Fatalf("expected error %v; got %v", tc.err, err)
296 }
297 if got.IsFinished() != tc.finished {
298 t.Fatalf("expected %v; got %v", tc.finished, got.IsFinished())
299 }
300 })
301 }
302}
303
304func TestDNSResolve(t *testing.T) {
305 reqTestCases := map[string]struct {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected