Skip to content

Commit

Permalink
Merge from master
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan A. Good <[email protected]>
  • Loading branch information
nathanagood committed Oct 29, 2019
2 parents 0b82169 + dd0d18e commit 817b359
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## v0.19.2

- Fixed issue with the lease check logic that was expiring non-expired leases.

## v0.19.1

- Resolved issue that lease active reason was not set upon lease creation.
- Fixed issue with lease status reason not being set when the lease was newly created.

## v0.19.0

Expand Down
2 changes: 1 addition & 1 deletion cmd/lambda/update_lease_status/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func lambdaHandler(input *lambdaHandlerInput) error {
// expired, given the context.
func isLeaseExpired(lease *db.RedboxLease, context *leaseContext) (bool, db.LeaseStatusReason) {

if context.expireDate <= lease.ExpiresOn {
if context.expireDate >= lease.ExpiresOn {
return true, db.LeaseExpired
} else if context.actualSpend >= lease.BudgetAmount {
return true, db.LeaseOverBudget
Expand Down
7 changes: 4 additions & 3 deletions cmd/lambda/update_lease_status/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ has exceeded its budget of $100. Actual spend is $150
BudgetCurrency: "USD",
BudgetNotificationEmails: []string{"[email protected]", "[email protected]"},
LeaseStatusModifiedOn: time.Unix(100, 0).Unix(),
ExpiresOn: time.Now().AddDate(0, 0, +1000).Unix(), //Make sure it expires in the distant future as we aren't testing that
},
awsSession: &awsMocks.AwsSession{},
tokenSvc: tokenSvc,
Expand Down Expand Up @@ -309,19 +310,19 @@ func Test_isLeaseExpired(t *testing.T) {
nonExpiredLeaseTestArgs := &args{
lease,
&leaseContext{
time.Now().AddDate(0, 0, +1).Unix(),
time.Now().AddDate(0, 0, -1).Unix(),
10}}

expiredLeaseTestArgs := &args{
lease,
&leaseContext{
time.Now().AddDate(0, 0, -1).Unix(),
time.Now().AddDate(0, 0, +1).Unix(),
10}}

overBudgetTest := &args{
lease,
&leaseContext{
time.Now().AddDate(0, 0, +1).Unix(),
time.Now().AddDate(0, 0, -1).Unix(),
5000}}

tests := []struct {
Expand Down

0 comments on commit 817b359

Please sign in to comment.