storj/satellite/payments/coupons_test.go
Bill Thorp 94c11c5212 satellite: remove some unnecessary UTC() calls
Fixes some easy cases of extraneous UTC() calls

Change-Id: I3f4c287ae622a455b9a492a8892a699e0710ca9a
2020-03-13 13:49:44 +00:00

38 lines
706 B
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package payments
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestCouponIsExpired(t *testing.T) {
duration := 2
now := time.Now()
testCases := [...]struct {
created time.Time
expected bool
}{
{now.AddDate(0, -duration-1, 0), true},
{now.AddDate(0, -duration-2, 0), true},
{now.AddDate(0, -duration-3, 0), true},
{now.AddDate(0, -1, 0), false},
{now.AddDate(0, 0, 0), false},
{now.AddDate(0, 1, 0), false},
}
for _, tc := range testCases {
coupon := Coupon{
Duration: duration,
Created: tc.created,
}
require.Equal(t, coupon.IsExpired(), tc.expected)
}
}