Skip to content

Commit

Permalink
Reduce user trial length
Browse files Browse the repository at this point in the history
  • Loading branch information
rndstr committed Aug 29, 2018
1 parent 7047e80 commit 56eeb06
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion billing-api/trial/trial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestTrialInfo(t *testing.T) {
TrialExpiresAt: now.Add(asDays(20) + 1*time.Hour),
},
trial: trial.Trial{
Length: int(users.TrialDuration.Hours() / 24),
Length: 30,
Remaining: 21,
Start: now.Add(asDays(-10) + 1*time.Hour),
End: now.Add(asDays(20) + 1*time.Hour),
Expand Down
6 changes: 3 additions & 3 deletions users/api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ func TestAPI_adminTrial(t *testing.T) {
defer cleanup(t)

usr, org := getOrg(t)
assert.Equal(t, 30, org.TrialRemaining(), "trial is not 30 days on instance creation")
assert.Equal(t, 14, org.TrialRemaining(), "trial is not 14 days on instance creation")

{ // Cannot shrink
w := httptest.NewRecorder()
r := requestAs(t, usr, "POST", fmt.Sprintf("/admin/users/organizations/%s/trial", org.ExternalID), strings.NewReader("remaining=29"))
r := requestAs(t, usr, "POST", fmt.Sprintf("/admin/users/organizations/%s/trial", org.ExternalID), strings.NewReader("remaining=9"))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
app.ServeHTTP(w, r)
assert.Equal(t, http.StatusFound, w.Code)

org, err := database.FindOrganizationByID(context.TODO(), org.ExternalID)
assert.NoError(t, err)
assert.Equal(t, 30, org.TrialRemaining())
assert.Equal(t, 14, org.TrialRemaining())
}
{ // but can expand
w := httptest.NewRecorder()
Expand Down
2 changes: 1 addition & 1 deletion users/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
const (
// TrialExtensionDuration is the extension period if billing is
// enabled for an existing customer
TrialExtensionDuration = 15 * 24 * time.Hour
TrialExtensionDuration = 7 * 24 * time.Hour

// TrialRefuseDataUploadAfter is the period after the trial expired before an
// instance's data upload is restricted.
Expand Down
2 changes: 1 addition & 1 deletion users/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// TrialDuration is how long a user has a free trial
// period before we start charging for it.
const TrialDuration = 30 * 24 * time.Hour
const TrialDuration = 14 * 24 * time.Hour

// FindUserByIDer is an interface of just FindUserByID, for loosely coupling
// things to the db.DB
Expand Down

0 comments on commit 56eeb06

Please sign in to comment.