cmd/satellite: choose correct Stripe client also for commands

Commands were using always real Strip client but for e.g. storj-sim
should use mock by default.

Change-Id: Ifd3c02028312d2e8d6d73d67b2dadadcd69077c8
This commit is contained in:
Michal Niewrzal 2020-06-15 12:54:42 +02:00 committed by Stefan Benten
parent b72bf4a6d8
commit 7a0778fac4
3 changed files with 18 additions and 1 deletions

View File

@ -60,7 +60,13 @@ func runBillingCmd(cmdFunc func(*stripecoinpayments.Service, *dbx.DB) error) err
func setupPayments(log *zap.Logger, db satellite.DB) (*stripecoinpayments.Service, error) {
pc := runCfg.Payments
stripeClient := stripecoinpayments.NewStripeClient(log, pc.StripeCoinPayments)
var stripeClient stripecoinpayments.StripeClient
switch pc.Provider {
default:
stripeClient = stripecoinpayments.NewStripeMock()
case "stripecoinpayments":
stripeClient = stripecoinpayments.NewStripeClient(log, pc.StripeCoinPayments)
}
return stripecoinpayments.NewService(
log.Named("payments.stripe:service"),

10
scripts/test-billing.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -ueo pipefail
PERIOD=$(date --date='-1 month' +%m/%Y)
satellite --config-dir $SATELLITE_0_DIR billing prepare-invoice-records $PERIOD
satellite --config-dir $SATELLITE_0_DIR billing create-invoice-items $PERIOD
satellite --config-dir $SATELLITE_0_DIR billing create-invoice-coupons $PERIOD
satellite --config-dir $SATELLITE_0_DIR billing create-invoice-credits $PERIOD
satellite --config-dir $SATELLITE_0_DIR billing create-invoices $PERIOD
satellite --config-dir $SATELLITE_0_DIR billing finalize-invoices $PERIOD

View File

@ -36,6 +36,7 @@ fi
# run aws-cli tests
storj-sim -x --satellites 1 --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-uplink.sh
storj-sim -x --satellites 1 --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-uplink-share.sh
storj-sim -x --satellites 1 --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-billing.sh
storj-sim -x --satellites 1 --host $STORJ_NETWORK_HOST4 network destroy
# setup the network with ipv6