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
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
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/storagenode/orders"
|
|
)
|
|
|
|
func TestOrders_Trivial(t *testing.T) {
|
|
Run(t, func(t *testing.T, ctx context.Context, db *DB) {
|
|
satelliteID, serial := testrand.NodeID(), testrand.SerialNumber()
|
|
|
|
{ // Ensure Enqueue works at all
|
|
err := db.Orders().Enqueue(ctx, &orders.Info{
|
|
Order: &pb.Order{},
|
|
Limit: &pb.OrderLimit{
|
|
SatelliteId: satelliteID,
|
|
SerialNumber: serial,
|
|
OrderExpiration: time.Now(),
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure ListUnsent works at all
|
|
_, err := db.Orders().ListUnsent(ctx, 1)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure ListUnsentBySatellite works at all
|
|
_, err := db.Orders().ListUnsentBySatellite(ctx)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure Archive works at all
|
|
err := db.Orders().Archive(ctx, satelliteID, serial, orders.StatusAccepted)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
{ // Ensure ListArchived works at all
|
|
_, err := db.Orders().ListArchived(ctx, 1)
|
|
require.NoError(t, err)
|
|
}
|
|
})
|
|
}
|