Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package network_test
  2. import (
  3. "context"
  4. "net"
  5. "net/http/httptest"
  6. "strings"
  7. "github.com/mccutchen/go-httpbin/httpbin"
  8. "github.com/stretchr/testify/mock"
  9. "github.com/stretchr/testify/suite"
  10. )
  11. type DialerMock struct {
  12. mock.Mock
  13. }
  14. func (d *DialerMock) Dial(network, address string) (net.Conn, error) {
  15. args := d.Called(network, address)
  16. return args.Get(0).(net.Conn), args.Error(1)
  17. }
  18. func (d *DialerMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
  19. args := d.Called(ctx, network, address)
  20. return args.Get(0).(net.Conn), args.Error(1)
  21. }
  22. type HTTPServerTestSuite struct {
  23. suite.Suite
  24. httpServer *httptest.Server
  25. }
  26. func (suite *HTTPServerTestSuite) SetupSuite() {
  27. suite.httpServer = httptest.NewServer(httpbin.NewHTTPBin().Handler())
  28. }
  29. func (suite *HTTPServerTestSuite) TearDownSuite() {
  30. suite.httpServer.Close()
  31. }
  32. func (suite *HTTPServerTestSuite) HTTPServerAddress() string {
  33. return strings.TrimPrefix(suite.httpServer.URL, "http://")
  34. }