Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing tests with time.Now #1539

Merged
merged 4 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ else
go test -p 1 -count 1 -short $$(go list ./... | grep \\/cmd\\/webserver) 2> /dev/null
endif

server_test: server_deps server_generate db_test_run db_test_reset db_test_migrate
server_test: server_deps server_generate db_test_reset db_test_run db_test_migrate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db_test_reset calls db_test_run, so I think you can just remove it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no reason to add db_test_run here.

# Don't run tests in /cmd or /pkg/gen & pass `-short` to exclude long running tests
# Use -test.parallel 1 to test packages serially and avoid database collisions
# Disable test caching with `-count 1` - caching was masking local test failures
Expand Down
14 changes: 9 additions & 5 deletions pkg/handlers/internalapi/personally_procured_move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func (suite *HandlerSuite) TestPatchPPMHandler() {
initialWeight := swag.Int64(4100)
newWeight := swag.Int64(4105)

initialMoveDate := time.Now().Add(-2 * 24 * time.Hour)
newMoveDate := time.Now()
// Date picked essentialy at random, but needs to be within TestYear
newMoveDate := time.Date(testdatagen.TestYear, time.November, 10, 23, 0, 0, 0, time.UTC)
initialMoveDate := newMoveDate.Add(-2 * 24 * time.Hour)

hasAdditionalPostalCode := swag.Bool(true)
newHasAdditionalPostalCode := swag.Bool(false)
Expand Down Expand Up @@ -254,7 +255,8 @@ func (suite *HandlerSuite) TestPatchPPMHandlerSetWeightLater() {

weight := swag.Int64(4100)

moveDate := time.Now()
// Date picked essentialy at random, but needs to be within TestYear
moveDate := time.Date(testdatagen.TestYear, time.November, 10, 23, 0, 0, 0, time.UTC)

pickupPostalCode := swag.String("32168")
destinationPostalCode := swag.String("29401")
Expand Down Expand Up @@ -326,8 +328,10 @@ func (suite *HandlerSuite) TestPatchPPMHandlerWrongUser() {
newSize := internalmessages.TShirtSize("L")
initialWeight := swag.Int64(1)
newWeight := swag.Int64(5)
initialMoveDate := time.Now().Add(-2 * 24 * time.Hour)
newMoveDate := time.Now()

// Date picked essentialy at random, but needs to be within TestYear
newMoveDate := time.Date(testdatagen.TestYear, time.November, 10, 23, 0, 0, 0, time.UTC)
initialMoveDate := newMoveDate.Add(-2 * 24 * time.Hour)

user2 := testdatagen.MakeDefaultServiceMember(suite.TestDB())
move := testdatagen.MakeDefaultMove(suite.TestDB())
Expand Down