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.

init_test.go 794B

12345678910111213141516171819202122232425262728293031323334353637
  1. package cli_test
  2. import (
  3. "net/http"
  4. "github.com/9seconds/mtg/v2/cli"
  5. "github.com/9seconds/mtg/v2/internal/testlib"
  6. "github.com/jarcoal/httpmock"
  7. "github.com/stretchr/testify/mock"
  8. "github.com/stretchr/testify/suite"
  9. )
  10. type CommonTestSuite struct {
  11. suite.Suite
  12. cli *cli.CLI
  13. networkMock *testlib.MtglibNetworkMock
  14. httpClient *http.Client
  15. }
  16. func (suite *CommonTestSuite) SetupTest() {
  17. suite.networkMock = &testlib.MtglibNetworkMock{}
  18. suite.httpClient = &http.Client{}
  19. suite.cli = &cli.CLI{}
  20. httpmock.ActivateNonDefault(suite.httpClient)
  21. suite.networkMock.
  22. On("MakeHTTPClient", mock.Anything).
  23. Maybe().
  24. Return(suite.httpClient)
  25. }
  26. func (suite *CommonTestSuite) TearDownTest() {
  27. suite.networkMock.AssertExpectations(suite.T())
  28. httpmock.DeactivateAndReset()
  29. }