app_test.go 707 B

1234567891011121314151617181920212223242526272829
  1. package commands
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func Test_resolverAddress(t *testing.T) {
  7. tests := []struct {
  8. addr string
  9. want string
  10. }{
  11. {"1.1.1.1", "1.1.1.1:53"},
  12. {"1.1.1.1:53", "1.1.1.1:53"},
  13. {"1.1.1.1:5353", "1.1.1.1:5353"},
  14. {"dns.example.com", "dns.example.com:53"},
  15. {"dns.example.com:5353", "dns.example.com:5353"},
  16. {"2606:4700:4700::1111", "[2606:4700:4700::1111]:53"},
  17. {"[2606:4700:4700::1111]", "[2606:4700:4700::1111]:53"},
  18. {"[2606:4700:4700::1111]:5353", "[2606:4700:4700::1111]:5353"},
  19. {"::1", "[::1]:53"},
  20. }
  21. for _, tt := range tests {
  22. t.Run(tt.addr, func(t *testing.T) {
  23. assert.Equal(t, tt.want, resolverAddress(tt.addr))
  24. })
  25. }
  26. }