mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:24:02 +03:00
Rename network_mock to mtglib_netwock_mock
This commit is contained in:
+2
-2
@@ -14,12 +14,12 @@ type CommonTestSuite struct {
|
|||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
cli *cli.CLI
|
cli *cli.CLI
|
||||||
networkMock *testlib.NetworkMock
|
networkMock *testlib.MtglibNetworkMock
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CommonTestSuite) SetupTest() {
|
func (suite *CommonTestSuite) SetupTest() {
|
||||||
suite.networkMock = &testlib.NetworkMock{}
|
suite.networkMock = &testlib.MtglibNetworkMock{}
|
||||||
suite.httpClient = &http.Client{}
|
suite.httpClient = &http.Client{}
|
||||||
suite.cli = &cli.CLI{}
|
suite.cli = &cli.CLI{}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package testlib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MtglibNetworkMock struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *MtglibNetworkMock) Dial(network, address string) (net.Conn, error) {
|
||||||
|
args := n.Called(network, address)
|
||||||
|
|
||||||
|
return args.Get(0).(net.Conn), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
args := n.Called(ctx, network, address)
|
||||||
|
|
||||||
|
return args.Get(0).(net.Conn), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
|
||||||
|
network, address string) (net.Conn, error)) *http.Client {
|
||||||
|
return m.Called(dialFunc).Get(0).(*http.Client)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MtglibNetworkMock) IdleTimeout() time.Duration {
|
||||||
|
return m.Called().Get(0).(time.Duration)
|
||||||
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package testlib
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/mock"
|
|
||||||
)
|
|
||||||
|
|
||||||
type NetworkMock struct {
|
|
||||||
mock.Mock
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NetworkMock) Dial(network, address string) (net.Conn, error) {
|
|
||||||
args := n.Called(network, address)
|
|
||||||
|
|
||||||
return args.Get(0).(net.Conn), args.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NetworkMock) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
||||||
args := n.Called(ctx, network, address)
|
|
||||||
|
|
||||||
return args.Get(0).(net.Conn), args.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
|
|
||||||
network, address string) (net.Conn, error)) *http.Client {
|
|
||||||
return n.Called(dialFunc).Get(0).(*http.Client)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NetworkMock) IdleTimeout() time.Duration {
|
|
||||||
return n.Called().Get(0).(time.Duration)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user