Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jun 17, 2020
1 parent 6b47ed4 commit c743fa1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions models/topups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/nyaruka/mailroom/testsuite"

"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -61,4 +62,11 @@ func TestTopups(t *testing.T) {
assert.Equal(t, tc.TopupID, topup)
tx.MustExec(`INSERT INTO orgs_topupcredits(is_squashed, used, topup_id) VALUES(TRUE, 1, $1)`, tc.OrgID)
}

// topups can be disabled for orgs
tx.MustExec(`UPDATE orgs_org SET uses_topups = FALSE WHERE id = $1`, Org1)
org, err := loadOrg(ctx, tx, Org1)
topup, err := AllocateTopups(ctx, tx, rc, org, 1)
assert.NoError(t, err)
assert.Equal(t, NilTopupID, topup)
}

0 comments on commit c743fa1

Please sign in to comment.