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
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

network_mock.go 773B

1234567891011121314151617181920212223242526272829303132333435
  1. package testlib
  2. import (
  3. "context"
  4. "net"
  5. "net/http"
  6. "time"
  7. "github.com/stretchr/testify/mock"
  8. )
  9. type NetworkMock struct {
  10. mock.Mock
  11. }
  12. func (n *NetworkMock) Dial(network, address string) (net.Conn, error) {
  13. args := n.Called(network, address)
  14. return args.Get(0).(net.Conn), args.Error(1)
  15. }
  16. func (n *NetworkMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
  17. args := n.Called(ctx, network, address)
  18. return args.Get(0).(net.Conn), args.Error(1)
  19. }
  20. func (n *NetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
  21. network, address string) (net.Conn, error)) *http.Client {
  22. return n.Called(dialFunc).Get(0).(*http.Client)
  23. }
  24. func (n *NetworkMock) IdleTimeout() time.Duration {
  25. return n.Called().Get(0).(time.Duration)
  26. }