url_connectedness_helper_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package url_connectedness_helper
  2. import "testing"
  3. func TestUrlConnectednessTest(t *testing.T) {
  4. type args struct {
  5. testUrl string
  6. proxyAddr string
  7. }
  8. tests := []struct {
  9. name string
  10. args args
  11. want bool
  12. wantErr bool
  13. }{
  14. {name: "0", args: args{
  15. testUrl: "https://google.com",
  16. proxyAddr: "",
  17. }, want: false, wantErr: true},
  18. {name: "1", args: args{
  19. testUrl: "https://google.com",
  20. proxyAddr: "",
  21. }, want: false, wantErr: true},
  22. {name: "2", args: args{
  23. testUrl: "https://google.com",
  24. proxyAddr: "",
  25. }, want: false, wantErr: true},
  26. {name: "3", args: args{
  27. testUrl: "https://google.com",
  28. proxyAddr: "",
  29. }, want: false, wantErr: true},
  30. {name: "4", args: args{
  31. testUrl: "https://google.com",
  32. proxyAddr: "http://192.168.50.252:20172",
  33. }, want: true, wantErr: false},
  34. }
  35. for _, tt := range tests {
  36. t.Run(tt.name, func(t *testing.T) {
  37. got, _, err := UrlConnectednessTest(tt.args.testUrl, tt.args.proxyAddr)
  38. if (err != nil) != tt.wantErr {
  39. t.Errorf("UrlConnectednessTest() error = %v, wantErr %v", err, tt.wantErr)
  40. return
  41. }
  42. if got != tt.want {
  43. t.Errorf("UrlConnectednessTest() got = %v, want %v", got, tt.want)
  44. }
  45. })
  46. }
  47. }