Skip to content

Commit

Permalink
Extend client.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Sep 26, 2024
1 parent cd0e5c2 commit a773e88
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 35 deletions.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ go 1.23

require (
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.64.0
google.golang.org/grpc v1.67.0
google.golang.org/protobuf v1.34.2
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
5 changes: 5 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type AccountingClient interface {
Health() healthv1.HealthClient
Postgres() v1.PostgresServiceClient
Machine() v1.MachineServiceClient
MachineReservation() v1.MachineReservationServiceClient
ProductOption() v1.ProductOptionServiceClient
Close() error
}
Expand Down Expand Up @@ -134,6 +135,10 @@ func (c client) Machine() v1.MachineServiceClient {
return v1.NewMachineServiceClient(c.conn)
}

func (c client) MachineReservation() v1.MachineReservationServiceClient {
return v1.NewMachineReservationServiceClient(c.conn)
}

func (c client) ProductOption() v1.ProductOptionServiceClient {
return v1.NewProductOptionServiceClient(c.conn)
}
50 changes: 30 additions & 20 deletions test/client/mock-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,31 @@ import (
)

type AccountingMockFns struct {
Cluster func(mock *mock.Mock)
Pod func(mock *mock.Mock)
S3 func(mock *mock.Mock)
IP func(mock *mock.Mock)
Info func(mock *mock.Mock)
NetworkTraffic func(mock *mock.Mock)
Volume func(mock *mock.Mock)
Postgres func(mock *mock.Mock)
ProductOption func(mock *mock.Mock)
Machine func(mock *mock.Mock)
Cluster func(mock *mock.Mock)
Pod func(mock *mock.Mock)
S3 func(mock *mock.Mock)
IP func(mock *mock.Mock)
Info func(mock *mock.Mock)
NetworkTraffic func(mock *mock.Mock)
Volume func(mock *mock.Mock)
Postgres func(mock *mock.Mock)
ProductOption func(mock *mock.Mock)
Machine func(mock *mock.Mock)
MachineReservation func(mock *mock.Mock)
}

type AccountingMockClient struct {
ClusterService *accmocks.ClusterServiceClient
PodService *accmocks.PodServiceClient
S3Service *accmocks.S3ServiceClient
IPService *accmocks.IPServiceClient
InfoService *accmocks.InfoServiceClient
NetworkTrafficService *accmocks.NetworkTrafficServiceClient
VolumeService *accmocks.VolumeServiceClient
PostgresService *accmocks.PostgresServiceClient
ProductOptionService *accmocks.ProductOptionServiceClient
MachineService *accmocks.MachineServiceClient
ClusterService *accmocks.ClusterServiceClient
PodService *accmocks.PodServiceClient
S3Service *accmocks.S3ServiceClient
IPService *accmocks.IPServiceClient
InfoService *accmocks.InfoServiceClient
NetworkTrafficService *accmocks.NetworkTrafficServiceClient
VolumeService *accmocks.VolumeServiceClient
PostgresService *accmocks.PostgresServiceClient
ProductOptionService *accmocks.ProductOptionServiceClient
MachineService *accmocks.MachineServiceClient
MachineReservationService *accmocks.MachineReservationServiceClient
}

func NewAccountingMockClient(mockFns *AccountingMockFns) (*AccountingMockClient, accountingclient.AccountingClient) {
Expand Down Expand Up @@ -82,6 +84,9 @@ func NewAccountingMockClient(mockFns *AccountingMockFns) (*AccountingMockClient,
if mockFns.Machine != nil {
mockFns.Machine(&a.MachineService.Mock)
}
if mockFns.MachineReservation != nil {
mockFns.MachineReservation(&a.MachineReservationService.Mock)
}
}

return a, a
Expand Down Expand Up @@ -135,6 +140,10 @@ func (c *AccountingMockClient) Machine() v1.MachineServiceClient {
return c.MachineService
}

func (c *AccountingMockClient) MachineReservation() v1.MachineReservationServiceClient {
return c.MachineReservationService
}

func (c *AccountingMockClient) AssertExpectations(t *testing.T) {
_ = c.ClusterService.AssertExpectations(t)
_ = c.PodService.AssertExpectations(t)
Expand All @@ -146,4 +155,5 @@ func (c *AccountingMockClient) AssertExpectations(t *testing.T) {
_ = c.PostgresService.AssertExpectations(t)
_ = c.ProductOptionService.AssertExpectations(t)
_ = c.MachineService.AssertExpectations(t)
_ = c.MachineReservationService.AssertExpectations(t)
}

0 comments on commit a773e88

Please sign in to comment.