(t *testing.T)
| 560 | } |
| 561 | |
| 562 | func TestIsValidTarget(t *testing.T) { |
| 563 | testCases := map[string]struct { |
| 564 | t string |
| 565 | valid bool |
| 566 | }{ |
| 567 | "Empty target": {"", false}, |
| 568 | "Invalid hostname": {"meep", false}, |
| 569 | "No TLD": {"meep.", false}, |
| 570 | "Invalid TLD": {"meep.123", false}, |
| 571 | "Valid hostname": {"meep.com", true}, |
| 572 | "Invalid IPv4": {"123.644.123.123", false}, |
| 573 | "Valid IPv4": {"123.123.123.123", true}, |
| 574 | "Invalid IPv6": {"123:123", false}, |
| 575 | "Valid IPv6": {"2001:db8::68", true}, |
| 576 | } |
| 577 | for name, tc := range testCases { |
| 578 | t.Run(name, func(t *testing.T) { |
| 579 | got := isValidTarget(tc.t) |
| 580 | if got != tc.valid { |
| 581 | t.Fatalf("expected %v; got %v", tc.valid, got) |
| 582 | } |
| 583 | }) |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | func TestIsValidLimit(t *testing.T) { |
| 588 | testCases := map[string]struct { |
nothing calls this directly
no test coverage detected