refactor: use shared mocks for tests
This commit is contained in:
@@ -5,6 +5,7 @@ go 1.25.0
|
||||
require (
|
||||
cloud.google.com/go/firestore v1.21.0
|
||||
cloud.google.com/go/storage v1.59.1
|
||||
firebase.google.com/go/v4 v4.19.0
|
||||
github.com/deepgram/deepgram-go-sdk/v3 v3.5.0
|
||||
github.com/golang-migrate/migrate/v4 v4.19.1
|
||||
github.com/google/uuid v1.6.0
|
||||
@@ -19,6 +20,7 @@ require (
|
||||
github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0
|
||||
go.jetify.com/typeid v1.3.0
|
||||
go.uber.org/mock v0.6.0
|
||||
google.golang.org/api v0.256.0
|
||||
google.golang.org/grpc v1.79.1
|
||||
google.golang.org/protobuf v1.36.11
|
||||
nhooyr.io/websocket v1.8.17
|
||||
@@ -37,7 +39,6 @@ require (
|
||||
cloud.google.com/go/longrunning v0.7.0 // indirect
|
||||
cloud.google.com/go/monitoring v1.24.2 // indirect
|
||||
dario.cat/mergo v1.0.2 // indirect
|
||||
firebase.google.com/go/v4 v4.19.0 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.54.0 // indirect
|
||||
@@ -176,7 +177,6 @@ require (
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
google.golang.org/api v0.256.0 // indirect
|
||||
google.golang.org/appengine/v2 v2.0.6 // indirect
|
||||
google.golang.org/genproto v0.0.0-20250922171735-9219d122eba9 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
|
||||
|
||||
@@ -483,7 +483,6 @@ gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/api v0.256.0 h1:u6Khm8+F9sxbCTYNoBHg6/Hwv0N/i+V94MvkOSor6oI=
|
||||
google.golang.org/api v0.256.0/go.mod h1:KIgPhksXADEKJlnEoRa9qAII4rXcy40vfI8HRqcU964=
|
||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
||||
google.golang.org/appengine/v2 v2.0.6 h1:LvPZLGuchSBslPBp+LAhihBeGSiRh1myRoYK4NtuBIw=
|
||||
google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7Z1JKf3J3wLI=
|
||||
google.golang.org/genproto v0.0.0-20250922171735-9219d122eba9 h1:LvZVVaPE0JSqL+ZWb6ErZfnEOKIqqFWUJE2D0fObSmc=
|
||||
|
||||
@@ -57,10 +57,7 @@ type serviceImpl struct {
|
||||
repo repository
|
||||
aeroSvc pbaero.PrimaryClient
|
||||
billingSvc billing.Service
|
||||
// fs mirrors network membership into humans/{humanId}.networks so
|
||||
// Firestore security rules can check membership at rule-eval time.
|
||||
// May be nil in services that never mutate membership (pusher).
|
||||
fs *firestore.Client
|
||||
fs *firestore.Client
|
||||
}
|
||||
|
||||
func NewService(pool *pgxpool.Pool, aeroSvc pbaero.PrimaryClient, billingSvc billing.Service, fs *firestore.Client) Service {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
"github.com/flowy-live/llink/internal/billing"
|
||||
"github.com/flowy-live/llink/internal/network"
|
||||
"github.com/flowy-live/llink/internal/network/mocks"
|
||||
"github.com/flowy-live/llink/internal/testhelper"
|
||||
"github.com/flowy-live/llink/internal/testhelper/mocks/aero"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
@@ -27,7 +27,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
func newTestService(t *testing.T) network.Service {
|
||||
ctrl := gomock.NewController(t)
|
||||
mockAero := mocks.NewMockPrimaryClient(ctrl)
|
||||
mockAero := aero.NewMockPrimaryClient(ctrl)
|
||||
mockAero.EXPECT().
|
||||
ShootEmail(gomock.Any(), gomock.Any()).
|
||||
Return(&pbaero.ShootEmailResponse{}, nil).
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/flowy-live/llink/internal/billing"
|
||||
"github.com/flowy-live/llink/internal/network"
|
||||
"github.com/flowy-live/llink/internal/particle"
|
||||
"github.com/flowy-live/llink/internal/testhelper"
|
||||
"github.com/flowy-live/llink/internal/testhelper/mocks/mocknetwork"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var dbPool *pgxpool.Pool
|
||||
@@ -34,7 +34,7 @@ func getStreamStatus(data json.RawMessage) string {
|
||||
|
||||
func TestParticleService_CreateAndGet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network first
|
||||
@@ -73,7 +73,7 @@ func TestParticleService_CreateAndGet(t *testing.T) {
|
||||
|
||||
func TestParticleService_NestedParticles(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network
|
||||
@@ -119,7 +119,7 @@ func TestParticleService_NestedParticles(t *testing.T) {
|
||||
|
||||
func TestParticleService_CustomVisibility(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network with a member
|
||||
@@ -161,7 +161,7 @@ func TestParticleService_CustomVisibility(t *testing.T) {
|
||||
|
||||
func TestParticleService_UpdateAndDelete(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network
|
||||
@@ -199,7 +199,7 @@ func TestParticleService_UpdateAndDelete(t *testing.T) {
|
||||
|
||||
func TestParticleService_ListRootParticles(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network
|
||||
@@ -225,7 +225,7 @@ func TestParticleService_ListRootParticles(t *testing.T) {
|
||||
|
||||
func TestParticleService_OpenCloseStream(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network
|
||||
@@ -273,7 +273,7 @@ func TestParticleService_OpenCloseStream(t *testing.T) {
|
||||
|
||||
func TestParticleService_NotAStream(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network
|
||||
@@ -302,7 +302,7 @@ func TestParticleService_NotAStream(t *testing.T) {
|
||||
|
||||
func TestParticleService_AccessInheritance(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
networkSvc := network.NewService(dbPool, nil, billing.Noop(), nil)
|
||||
networkSvc := testhelper.NewNetworkService(t, dbPool)
|
||||
svc := particle.NewService(dbPool, networkSvc)
|
||||
|
||||
// Create a network with members
|
||||
|
||||
+3
-3
@@ -3,11 +3,11 @@
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=/Users/talksik/Documents/code/llink/go/genproto/aero/main_grpc.pb.go -destination=/Users/talksik/Documents/code/llink/go/internal/network/mocks/mock_aero.go -package=mocks
|
||||
// mockgen -source=/Users/talksik/Documents/code/llink/go/genproto/aero/main_grpc.pb.go -destination=/Users/talksik/Documents/code/llink/go/internal/testhelper/mocks/aero/mock_aero.go -package=aero
|
||||
//
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
// Package aero is a generated GoMock package.
|
||||
package aero
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@@ -0,0 +1,261 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: /Users/talksik/Documents/code/llink/go/internal/network/service.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=/Users/talksik/Documents/code/llink/go/internal/network/service.go -destination=/Users/talksik/Documents/code/llink/go/internal/testhelper/mocks/mocknetwork/mock_network.go -package=mocknetwork
|
||||
//
|
||||
|
||||
// Package mocknetwork is a generated GoMock package.
|
||||
package mocknetwork
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
network "github.com/flowy-live/llink/internal/network"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockService is a mock of Service interface.
|
||||
type MockService struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockServiceMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockServiceMockRecorder is the mock recorder for MockService.
|
||||
type MockServiceMockRecorder struct {
|
||||
mock *MockService
|
||||
}
|
||||
|
||||
// NewMockService creates a new mock instance.
|
||||
func NewMockService(ctrl *gomock.Controller) *MockService {
|
||||
mock := &MockService{ctrl: ctrl}
|
||||
mock.recorder = &MockServiceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockService) EXPECT() *MockServiceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AcceptInvitation mocks base method.
|
||||
func (m *MockService) AcceptInvitation(ctx context.Context, networkID, email, humanId string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AcceptInvitation", ctx, networkID, email, humanId)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AcceptInvitation indicates an expected call of AcceptInvitation.
|
||||
func (mr *MockServiceMockRecorder) AcceptInvitation(ctx, networkID, email, humanId any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptInvitation", reflect.TypeOf((*MockService)(nil).AcceptInvitation), ctx, networkID, email, humanId)
|
||||
}
|
||||
|
||||
// AddMembers mocks base method.
|
||||
func (m *MockService) AddMembers(ctx context.Context, networkID string, humanIds []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddMembers", ctx, networkID, humanIds)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddMembers indicates an expected call of AddMembers.
|
||||
func (mr *MockServiceMockRecorder) AddMembers(ctx, networkID, humanIds any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddMembers", reflect.TypeOf((*MockService)(nil).AddMembers), ctx, networkID, humanIds)
|
||||
}
|
||||
|
||||
// CountSeats mocks base method.
|
||||
func (m *MockService) CountSeats(ctx context.Context, networkID string) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CountSeats", ctx, networkID)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CountSeats indicates an expected call of CountSeats.
|
||||
func (mr *MockServiceMockRecorder) CountSeats(ctx, networkID any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountSeats", reflect.TypeOf((*MockService)(nil).CountSeats), ctx, networkID)
|
||||
}
|
||||
|
||||
// Create mocks base method.
|
||||
func (m *MockService) Create(ctx context.Context, name, adminHumanId string) (*network.Network, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Create", ctx, name, adminHumanId)
|
||||
ret0, _ := ret[0].(*network.Network)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Create indicates an expected call of Create.
|
||||
func (mr *MockServiceMockRecorder) Create(ctx, name, adminHumanId any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockService)(nil).Create), ctx, name, adminHumanId)
|
||||
}
|
||||
|
||||
// GetByID mocks base method.
|
||||
func (m *MockService) GetByID(ctx context.Context, id string) (*network.Network, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetByID", ctx, id)
|
||||
ret0, _ := ret[0].(*network.Network)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetByID indicates an expected call of GetByID.
|
||||
func (mr *MockServiceMockRecorder) GetByID(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockService)(nil).GetByID), ctx, id)
|
||||
}
|
||||
|
||||
// InviteByEmail mocks base method.
|
||||
func (m *MockService) InviteByEmail(ctx context.Context, networkID string, emails []string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InviteByEmail", ctx, networkID, emails)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// InviteByEmail indicates an expected call of InviteByEmail.
|
||||
func (mr *MockServiceMockRecorder) InviteByEmail(ctx, networkID, emails any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InviteByEmail", reflect.TypeOf((*MockService)(nil).InviteByEmail), ctx, networkID, emails)
|
||||
}
|
||||
|
||||
// IsMember mocks base method.
|
||||
func (m *MockService) IsMember(ctx context.Context, networkID, humanId string) (bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsMember", ctx, networkID, humanId)
|
||||
ret0, _ := ret[0].(bool)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// IsMember indicates an expected call of IsMember.
|
||||
func (mr *MockServiceMockRecorder) IsMember(ctx, networkID, humanId any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMember", reflect.TypeOf((*MockService)(nil).IsMember), ctx, networkID, humanId)
|
||||
}
|
||||
|
||||
// ListAll mocks base method.
|
||||
func (m *MockService) ListAll(ctx context.Context) ([]*network.Network, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListAll", ctx)
|
||||
ret0, _ := ret[0].([]*network.Network)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListAll indicates an expected call of ListAll.
|
||||
func (mr *MockServiceMockRecorder) ListAll(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAll", reflect.TypeOf((*MockService)(nil).ListAll), ctx)
|
||||
}
|
||||
|
||||
// ListAllMemberships mocks base method.
|
||||
func (m *MockService) ListAllMemberships(ctx context.Context) (map[string][]string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListAllMemberships", ctx)
|
||||
ret0, _ := ret[0].(map[string][]string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListAllMemberships indicates an expected call of ListAllMemberships.
|
||||
func (mr *MockServiceMockRecorder) ListAllMemberships(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAllMemberships", reflect.TypeOf((*MockService)(nil).ListAllMemberships), ctx)
|
||||
}
|
||||
|
||||
// ListForHuman mocks base method.
|
||||
func (m *MockService) ListForHuman(ctx context.Context, humanId string) ([]*network.Network, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListForHuman", ctx, humanId)
|
||||
ret0, _ := ret[0].([]*network.Network)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListForHuman indicates an expected call of ListForHuman.
|
||||
func (mr *MockServiceMockRecorder) ListForHuman(ctx, humanId any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListForHuman", reflect.TypeOf((*MockService)(nil).ListForHuman), ctx, humanId)
|
||||
}
|
||||
|
||||
// ListInvitationsForEmail mocks base method.
|
||||
func (m *MockService) ListInvitationsForEmail(ctx context.Context, email string) ([]*network.Invitation, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListInvitationsForEmail", ctx, email)
|
||||
ret0, _ := ret[0].([]*network.Invitation)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListInvitationsForEmail indicates an expected call of ListInvitationsForEmail.
|
||||
func (mr *MockServiceMockRecorder) ListInvitationsForEmail(ctx, email any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListInvitationsForEmail", reflect.TypeOf((*MockService)(nil).ListInvitationsForEmail), ctx, email)
|
||||
}
|
||||
|
||||
// ListInvitationsForNetwork mocks base method.
|
||||
func (m *MockService) ListInvitationsForNetwork(ctx context.Context, networkID string) ([]*network.Invitation, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListInvitationsForNetwork", ctx, networkID)
|
||||
ret0, _ := ret[0].([]*network.Invitation)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListInvitationsForNetwork indicates an expected call of ListInvitationsForNetwork.
|
||||
func (mr *MockServiceMockRecorder) ListInvitationsForNetwork(ctx, networkID any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListInvitationsForNetwork", reflect.TypeOf((*MockService)(nil).ListInvitationsForNetwork), ctx, networkID)
|
||||
}
|
||||
|
||||
// RemoveMember mocks base method.
|
||||
func (m *MockService) RemoveMember(ctx context.Context, networkID, humanId string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RemoveMember", ctx, networkID, humanId)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// RemoveMember indicates an expected call of RemoveMember.
|
||||
func (mr *MockServiceMockRecorder) RemoveMember(ctx, networkID, humanId any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveMember", reflect.TypeOf((*MockService)(nil).RemoveMember), ctx, networkID, humanId)
|
||||
}
|
||||
|
||||
// RevokeInvitation mocks base method.
|
||||
func (m *MockService) RevokeInvitation(ctx context.Context, networkID, email string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RevokeInvitation", ctx, networkID, email)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// RevokeInvitation indicates an expected call of RevokeInvitation.
|
||||
func (mr *MockServiceMockRecorder) RevokeInvitation(ctx, networkID, email any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeInvitation", reflect.TypeOf((*MockService)(nil).RevokeInvitation), ctx, networkID, email)
|
||||
}
|
||||
|
||||
// SetName mocks base method.
|
||||
func (m *MockService) SetName(ctx context.Context, id, name string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SetName", ctx, id, name)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetName indicates an expected call of SetName.
|
||||
func (mr *MockServiceMockRecorder) SetName(ctx, id, name any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetName", reflect.TypeOf((*MockService)(nil).SetName), ctx, id, name)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package testhelper
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
"github.com/flowy-live/llink/internal/billing"
|
||||
"github.com/flowy-live/llink/internal/network"
|
||||
"github.com/flowy-live/llink/internal/testhelper/mocks/aero"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
func NewNetworkService(t *testing.T, pool *pgxpool.Pool) network.Service {
|
||||
t.Helper()
|
||||
ctrl := gomock.NewController(t)
|
||||
mockAero := aero.NewMockPrimaryClient(ctrl)
|
||||
mockAero.EXPECT().
|
||||
ShootEmail(gomock.Any(), gomock.Any()).
|
||||
Return(&pbaero.ShootEmailResponse{}, nil).
|
||||
AnyTimes()
|
||||
return network.NewService(pool, mockAero, billing.Noop(), nil)
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: /Users/talksik/Documents/code/llink/go/genproto/aero/main_grpc.pb.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=/Users/talksik/Documents/code/llink/go/genproto/aero/main_grpc.pb.go -destination=/Users/talksik/Documents/code/llink/go/internal/waitlist/mocks/mock_aero.go -package=mocks
|
||||
//
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// MockPrimaryClient is a mock of PrimaryClient interface.
|
||||
type MockPrimaryClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockPrimaryClientMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockPrimaryClientMockRecorder is the mock recorder for MockPrimaryClient.
|
||||
type MockPrimaryClientMockRecorder struct {
|
||||
mock *MockPrimaryClient
|
||||
}
|
||||
|
||||
// NewMockPrimaryClient creates a new mock instance.
|
||||
func NewMockPrimaryClient(ctrl *gomock.Controller) *MockPrimaryClient {
|
||||
mock := &MockPrimaryClient{ctrl: ctrl}
|
||||
mock.recorder = &MockPrimaryClientMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockPrimaryClient) EXPECT() *MockPrimaryClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ShootEmail mocks base method.
|
||||
func (m *MockPrimaryClient) ShootEmail(ctx context.Context, in *pbaero.ShootEmailRequest, opts ...grpc.CallOption) (*pbaero.ShootEmailResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{ctx, in}
|
||||
for _, a := range opts {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "ShootEmail", varargs...)
|
||||
ret0, _ := ret[0].(*pbaero.ShootEmailResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ShootEmail indicates an expected call of ShootEmail.
|
||||
func (mr *MockPrimaryClientMockRecorder) ShootEmail(ctx, in any, opts ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]any{ctx, in}, opts...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ShootEmail", reflect.TypeOf((*MockPrimaryClient)(nil).ShootEmail), varargs...)
|
||||
}
|
||||
|
||||
// MockPrimaryServer is a mock of PrimaryServer interface.
|
||||
type MockPrimaryServer struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockPrimaryServerMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockPrimaryServerMockRecorder is the mock recorder for MockPrimaryServer.
|
||||
type MockPrimaryServerMockRecorder struct {
|
||||
mock *MockPrimaryServer
|
||||
}
|
||||
|
||||
// NewMockPrimaryServer creates a new mock instance.
|
||||
func NewMockPrimaryServer(ctrl *gomock.Controller) *MockPrimaryServer {
|
||||
mock := &MockPrimaryServer{ctrl: ctrl}
|
||||
mock.recorder = &MockPrimaryServerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockPrimaryServer) EXPECT() *MockPrimaryServerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ShootEmail mocks base method.
|
||||
func (m *MockPrimaryServer) ShootEmail(arg0 context.Context, arg1 *pbaero.ShootEmailRequest) (*pbaero.ShootEmailResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ShootEmail", arg0, arg1)
|
||||
ret0, _ := ret[0].(*pbaero.ShootEmailResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ShootEmail indicates an expected call of ShootEmail.
|
||||
func (mr *MockPrimaryServerMockRecorder) ShootEmail(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ShootEmail", reflect.TypeOf((*MockPrimaryServer)(nil).ShootEmail), arg0, arg1)
|
||||
}
|
||||
|
||||
// mustEmbedUnimplementedPrimaryServer mocks base method.
|
||||
func (m *MockPrimaryServer) mustEmbedUnimplementedPrimaryServer() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "mustEmbedUnimplementedPrimaryServer")
|
||||
}
|
||||
|
||||
// mustEmbedUnimplementedPrimaryServer indicates an expected call of mustEmbedUnimplementedPrimaryServer.
|
||||
func (mr *MockPrimaryServerMockRecorder) mustEmbedUnimplementedPrimaryServer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "mustEmbedUnimplementedPrimaryServer", reflect.TypeOf((*MockPrimaryServer)(nil).mustEmbedUnimplementedPrimaryServer))
|
||||
}
|
||||
|
||||
// MockUnsafePrimaryServer is a mock of UnsafePrimaryServer interface.
|
||||
type MockUnsafePrimaryServer struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockUnsafePrimaryServerMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockUnsafePrimaryServerMockRecorder is the mock recorder for MockUnsafePrimaryServer.
|
||||
type MockUnsafePrimaryServerMockRecorder struct {
|
||||
mock *MockUnsafePrimaryServer
|
||||
}
|
||||
|
||||
// NewMockUnsafePrimaryServer creates a new mock instance.
|
||||
func NewMockUnsafePrimaryServer(ctrl *gomock.Controller) *MockUnsafePrimaryServer {
|
||||
mock := &MockUnsafePrimaryServer{ctrl: ctrl}
|
||||
mock.recorder = &MockUnsafePrimaryServerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockUnsafePrimaryServer) EXPECT() *MockUnsafePrimaryServerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// mustEmbedUnimplementedPrimaryServer mocks base method.
|
||||
func (m *MockUnsafePrimaryServer) mustEmbedUnimplementedPrimaryServer() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "mustEmbedUnimplementedPrimaryServer")
|
||||
}
|
||||
|
||||
// mustEmbedUnimplementedPrimaryServer indicates an expected call of mustEmbedUnimplementedPrimaryServer.
|
||||
func (mr *MockUnsafePrimaryServerMockRecorder) mustEmbedUnimplementedPrimaryServer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "mustEmbedUnimplementedPrimaryServer", reflect.TypeOf((*MockUnsafePrimaryServer)(nil).mustEmbedUnimplementedPrimaryServer))
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
"github.com/flowy-live/llink/internal/testhelper"
|
||||
"github.com/flowy-live/llink/internal/testhelper/mocks/aero"
|
||||
"github.com/flowy-live/llink/internal/waitlist"
|
||||
"github.com/flowy-live/llink/internal/waitlist/mocks"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
@@ -26,7 +26,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
func newTestService(t *testing.T) waitlist.Service {
|
||||
ctrl := gomock.NewController(t)
|
||||
mockAero := mocks.NewMockPrimaryClient(ctrl)
|
||||
mockAero := aero.NewMockPrimaryClient(ctrl)
|
||||
mockAero.EXPECT().
|
||||
ShootEmail(gomock.Any(), gomock.Any()).
|
||||
Return(&pbaero.ShootEmailResponse{}, nil).
|
||||
|
||||
Reference in New Issue
Block a user