diff --git a/CHANGELOG.md b/CHANGELOG.md index fafdba263..ad56b7bfb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/lambda/update_lease_status/main.go b/cmd/lambda/update_lease_status/main.go index 7cf427079..53359d958 100755 --- a/cmd/lambda/update_lease_status/main.go +++ b/cmd/lambda/update_lease_status/main.go @@ -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 diff --git a/cmd/lambda/update_lease_status/main_test.go b/cmd/lambda/update_lease_status/main_test.go index 741795eed..7c43a25ba 100755 --- a/cmd/lambda/update_lease_status/main_test.go +++ b/cmd/lambda/update_lease_status/main_test.go @@ -98,6 +98,7 @@ has exceeded its budget of $100. Actual spend is $150 BudgetCurrency: "USD", BudgetNotificationEmails: []string{"recipA@example.com", "recipB@example.com"}, 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, @@ -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 {