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

Use Utc times for integration tests #644

Merged
merged 5 commits into from
Jul 25, 2022

Conversation

LaurensVergote
Copy link
Contributor

Noticed a few of the integration tests failed when ran locally and decided to fix them.
The issue was that local timestamps were being compared with utc timestamps.
In .NET the DateTimeKind is not checked when comparing, so we must make sure these are the same.

scottf
scottf previously requested changes Jul 24, 2022
@@ -31,7 +31,7 @@ public void TestStreamCreate()
{
Context.RunInJsServer(c =>
{
DateTime now = DateTime.Now;
DateTime now = DateTime.UtcNow;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that you pointed this out I think it would be better to change the assertion on line 45 to normalize the data before comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a rule of thumb, it is best to work in UTC everywhere in the code until the point it needs to be displayed/logged. This way you avoid any confusion and potential errors due to winter/summer times.
I'll see what I can do for this commit

@@ -81,7 +81,7 @@ public void TestStreamCreate()
public void TestStreamCreateWithNoSubject() {
Context.RunInJsServer(c =>
{
DateTime now = DateTime.Now;
DateTime now = DateTime.UtcNow;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment on comparison line 94

@@ -639,7 +639,7 @@ public void TestGetStreams()
MsgHeader h = new MsgHeader();
h.Add("foo", "bar");

DateTime beforeCreated = DateTime.Now;
DateTime beforeCreated = DateTime.UtcNow; //MessageInfo.Time is in UTC
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix the comparison line 652, 660

@scottf
Copy link
Collaborator

scottf commented Jul 24, 2022

Copy link
Collaborator

@arondi arondi left a comment

Choose a reason for hiding this comment

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

LGTM

@scottf scottf dismissed their stale review July 25, 2022 15:50

Changes were addressed

@scottf
Copy link
Collaborator

scottf commented Jul 25, 2022

Admin merge - signing was added on most recent commits.

@scottf scottf merged commit 91460be into nats-io:master Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants