enable utccheck in all tests by default (#2565)
* enable utccheck in all tests by default
This commit is contained in:
parent
c12a4aed3b
commit
b51d3a69da
@ -6,13 +6,21 @@ package storagenodedb
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
)
|
||||
|
||||
// utcChecks controls if the time zone checks are enabled.
|
||||
var utcChecks = false
|
||||
// utcChecks controls if the time zone checks are enabled. They are by default
|
||||
// enabled only during tests.
|
||||
var utcChecks = len(os.Args) > 0 && strings.HasSuffix(os.Args[0], ".test")
|
||||
|
||||
// EnableUTCChecks turns on tracking for timestamps being passed to the database being in
|
||||
// the UTC location. They cannot be turned off once turned on, and should be turned on
|
||||
// before any database calls are made.
|
||||
func EnableUTCChecks() { utcChecks = true }
|
||||
|
||||
// utcDB wraps a sql.DB and checks all of the arguments to queries to ensure they are in UTC.
|
||||
type utcDB struct {
|
||||
|
@ -13,8 +13,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func init() { utcChecks = true }
|
||||
|
||||
func TestUTCDB(t *testing.T) {
|
||||
notUTC := time.FixedZone("not utc", -1)
|
||||
db := utcDB{sql.OpenDB(emptyConnector{})}
|
||||
|
Loading…
Reference in New Issue
Block a user