From 113eea174eb19b43ff2e3d2bfdbb7035fefdf277 Mon Sep 17 00:00:00 2001 From: "Nathan A. Good" Date: Mon, 28 Oct 2019 12:32:08 -0500 Subject: [PATCH 1/4] Updated CHANGELOG for v.0.19.1 Signed-off-by: Nathan A. Good --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7010024..e05f8ac88 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.19.1 + +- Fixed issue with lease status reason not being set when the lease was newly created. + ## v0.19.0 **BREAKING CHANGES** From f29cd3503be33adeb7ae05a30269c9f86098e4dd Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 29 Oct 2019 09:10:46 -0500 Subject: [PATCH 2/4] Switch the comparison operator on lease expiration Signed-off-by: Kevin DeJong --- cmd/lambda/update_lease_status/main.go | 2 +- cmd/lambda/update_lease_status/main_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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..88e316c33 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,13 +310,13 @@ 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{ From 63ac8e6a4f4332500dc1e3153af34cae541a0cbc Mon Sep 17 00:00:00 2001 From: "Nathan A. Good" Date: Tue, 29 Oct 2019 09:29:30 -0500 Subject: [PATCH 3/4] Updated CHANGELOG for v0.19.2 Signed-off-by: Nathan A. Good --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e05f8ac88..ad56b7bfb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.19.2 + +- Fixed issue with the lease check logic that was expiring non-expired leases. + ## v0.19.1 - Fixed issue with lease status reason not being set when the lease was newly created. From 02ea31b007232dc9428c1f91bf4911d03c91cb50 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 29 Oct 2019 09:36:44 -0500 Subject: [PATCH 4/4] Switch the comparison operator on lease expiration (#83) Signed-off-by: Kevin DeJong --- cmd/lambda/update_lease_status/main.go | 2 +- cmd/lambda/update_lease_status/main_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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 {