b9d8ddaad1
* storagenode: remove datetime calls in favor of UTC datetime only has second level granularity whereas string comparisons don't. Since we're wiping everything anyway, it's easier to just use UTC everywhere rather than migrate to datetime calls. * add utcdb to check that arguments are utc * storagenodedb: add trivial tests to ensure calls work This at least tests that all of the timestamps passed in are in the UTC timezone. * fix truncated comment and change migrations to be UTC
41 lines
867 B
Go
41 lines
867 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package storagenodedb
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/storj/internal/testrand"
|
|
"storj.io/storj/pkg/pb"
|
|
"storj.io/storj/pkg/storj"
|
|
)
|
|
|
|
func TestVouchers_Trivial(t *testing.T) {
|
|
Run(t, func(t *testing.T, ctx context.Context, db *DB) {
|
|
satelliteID := testrand.NodeID()
|
|
|
|
{ // Ensure Put works at all
|
|
err := db.Vouchers().Put(ctx, &pb.Voucher{
|
|
SatelliteId: satelliteID,
|
|
Expiration: time.Now(),
|
|
})
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure NeedVoucher works at all
|
|
_, err := db.Vouchers().NeedVoucher(ctx, satelliteID, time.Hour)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure GetValid works at all
|
|
_, err := db.Vouchers().GetValid(ctx, []storj.NodeID{satelliteID})
|
|
require.NoError(t, err)
|
|
}
|
|
})
|
|
}
|