Skip to content

Commit

Permalink
[usage] Fix content service nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ authored and roboquat committed Aug 30, 2022
1 parent dba77a5 commit 8b11db3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/usage/pkg/apiv1/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"gorm.io/gorm"
)

func NewBillingService(stripeClient *stripe.Client, billInstancesAfter time.Time, conn *gorm.DB) *BillingService {
func NewBillingService(stripeClient *stripe.Client, billInstancesAfter time.Time, conn *gorm.DB, contentService contentservice.Interface) *BillingService {
return &BillingService{
stripeClient: stripeClient,
billInstancesAfter: billInstancesAfter,
conn: conn,
contentService: contentService,
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/usage/pkg/apiv1/billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestCreditSummaryForTeams(t *testing.T) {

for _, s := range scenarios {
t.Run(s.Name, func(t *testing.T) {
svc := NewBillingService(&stripe.Client{}, s.BillSessionsAfter, &gorm.DB{})
svc := NewBillingService(&stripe.Client{}, s.BillSessionsAfter, &gorm.DB{}, nil)
actual, err := svc.creditSummaryForTeams(s.Sessions, reportID)
require.NoError(t, err)
require.Equal(t, s.Expected, actual)
Expand Down
2 changes: 1 addition & 1 deletion components/usage/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func registerGRPCServices(srv *baseserver.Server, conn *gorm.DB, stripeClient *s
if stripeClient == nil {
v1.RegisterBillingServiceServer(srv.GRPC(), &apiv1.BillingServiceNoop{})
} else {
v1.RegisterBillingServiceServer(srv.GRPC(), apiv1.NewBillingService(stripeClient, billInstancesAfter, conn))
v1.RegisterBillingServiceServer(srv.GRPC(), apiv1.NewBillingService(stripeClient, billInstancesAfter, conn, contentSvc))
}
return nil
}

0 comments on commit 8b11db3

Please sign in to comment.