satellite/admin: fix time issues in tests

With day -1 test was creating tallies for two different months.

Change-Id: I10201f4e787e73bae40bf7120856fb7cfdcd66f7
This commit is contained in:
Michal Niewrzal 2020-09-01 16:03:52 +02:00
parent 0604a672c1
commit 084e280a6d

View File

@ -306,11 +306,12 @@ func TestCheckUsageWithUsage(t *testing.T) {
err = planet.Satellites[0].DB.Console().APIKeys().Delete(ctx, apiKeys.APIKeys[0].ID)
require.NoError(t, err)
accTime := time.Now().UTC().AddDate(0, 0, -1)
now := time.Now().UTC()
// use fixed intervals to avoid issues at the beginning of the month
tally := accounting.BucketStorageTally{
BucketName: "test",
ProjectID: projectID,
IntervalStart: accTime,
IntervalStart: time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 1, time.UTC),
ObjectCount: 1,
InlineSegmentCount: 1,
RemoteSegmentCount: 1,
@ -323,7 +324,7 @@ func TestCheckUsageWithUsage(t *testing.T) {
tally = accounting.BucketStorageTally{
BucketName: "test",
ProjectID: projectID,
IntervalStart: accTime.AddDate(0, 0, 1),
IntervalStart: time.Date(now.Year(), now.Month(), 1, 0, 1, 0, 1, time.UTC),
ObjectCount: 1,
InlineSegmentCount: 1,
RemoteSegmentCount: 1,
@ -373,11 +374,12 @@ func TestDeleteProjectWithUsageCurrentMonth(t *testing.T) {
err = planet.Satellites[0].DB.Console().APIKeys().Delete(ctx, apiKeys.APIKeys[0].ID)
require.NoError(t, err)
accTime := time.Now().UTC().AddDate(0, 0, -1)
now := time.Now().UTC()
// use fixed intervals to avoid issues at the beginning of the month
tally := accounting.BucketStorageTally{
BucketName: "test",
ProjectID: projectID,
IntervalStart: accTime,
IntervalStart: time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 1, time.UTC),
ObjectCount: 1,
InlineSegmentCount: 1,
RemoteSegmentCount: 1,
@ -390,7 +392,7 @@ func TestDeleteProjectWithUsageCurrentMonth(t *testing.T) {
tally = accounting.BucketStorageTally{
BucketName: "test",
ProjectID: projectID,
IntervalStart: accTime.AddDate(0, 0, 1),
IntervalStart: time.Date(now.Year(), now.Month(), 1, 0, 1, 0, 1, time.UTC),
ObjectCount: 1,
InlineSegmentCount: 1,
RemoteSegmentCount: 1,