Created
July 27, 2020 14:12
-
-
Save meysampg/fce78508943063ab661a35a6cb98538f to your computer and use it in GitHub Desktop.
More readable to compare times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"time" | |
"github.com/stretchr/testify/assert" | |
) | |
func compareTimes(t assert.TestingT, expected, actual [2]time.Time) { | |
assertTruefTime(t, "start", expected[0], actual[0]) | |
assertTruefTime(t, "end", expected[1], actual[1]) | |
} | |
func assertTruefTime(t assert.TestingT, when string, expected, actual time.Time) { | |
assert.Truef(t, expected.Equal(actual), "%s: expected[%s] != actual[%s]", when, expected, actual) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment