Closed ArmaanMcleod closed 3 years ago
I guess another thing to consider is that should we separate the tests from the build? Like create a test.ps1
script that runs just the tests. At least this way builds will be quicker when running locally and don't rely on tests passing.
@ArmaanMcleod If just updating var utc = DateTime.Parse("2020-04-07 14:53:14Z", new CultureInfo("en-US")).ToUniversalTime();
alone fixes the issue I think that is fine. The intent it that it should be UTC anyway by specifying Z
in the time string. But unusual it is not automatically picking it up as UTC.
Does it fix the issue? or is the +1 hour also required?
@ArmaanMcleod
I guess another thing to consider is that should we separate the tests from the build? Like create a
test.ps1
script that runs just the tests. At least this way builds will be quicker when running locally and don't rely on tests passing.
Did you try the VSCode build task? Should work a treat to just build instead of build + test. But I'm open to this if you think it would improve your workflow. Feel free to open an issue and PR to close the loop. 😄
@ArmaanMcleod If just updating
var utc = DateTime.Parse("2020-04-07 14:53:14Z", new CultureInfo("en-US")).ToUniversalTime();
alone fixes the issue I think that is fine. The intent it that it should be UTC anyway by specifyingZ
in the time string. But unusual it is not automatically picking it up as UTC.Does it fix the issue? or is the +1 hour also required?
@BernieWhite Unfortunately the +1 is required. var utc = DateTime.Parse("2020-04-07 14:53:14Z", new CultureInfo("en-US")).ToUniversalTime();
does force the time format to be the same e.g. 2020-03-29T13:53:14.0000000Z
, but the hours are still 1 apart when doing Assert.Equal()
since utc.AddDays(-9)
gives back 2020-03-29T14:53:14.0000000Z
.
I have been fine so far without this test passing. I usually just build then run Invoke-Pester
on the tests I am changing to make sure the the changes I am making don't break anything.
Did you try the VSCode build task? Should work a treat to just build instead of build + test. But I'm open to this if you think it would improve your workflow. Feel free to open an issue and PR to close the loop. 😄.
Ah didn't realize that task existed, I think that should be fine 🎉 . I might add some extra documentation to https://github.com/Azure/PSRule.Rules.Azure/blob/main/docs/install-instructions.md#building-from-source to include this way for anyone else who is just wanting to do a simple build. Could include the handy Test
task as well. Thanks mate 🙂 .
@ArmaanMcleod Ok. I adjusted my time zone to match yours with DST enabled and can repo the issue.
Thanks @BernieWhite for looking into this 🙂. I knew it had something to do with DST but didn't get much time to look into the issue this week with all my customer work.
Description of the issue
When running
build.ps1
on my machine, I get the follow error fromDatetimeAdd
test:Code: https://github.com/Azure/PSRule.Rules.Azure/blob/main/tests/PSRule.Rules.Azure.Tests/FunctionTests.cs#L801-L820
Expected behaviour
Tests should pass. Although this seems like an issue on my machine with time zones. It seems to be the second assert that is problematic.
I can actually force this test to pass by doing this:
Which makes me believe this could be a DST issue, since adding an hour to the second Assert passes the test. Could be completely wrong about this 😄 . This definitely isn't a fix because the CI would break since it doesn't seem to be affected by this issue.
I could probably try reinstalling dotnet to see if that fixes the issue. Or we could set a specific time zone and use that?
Environment
$PSVersionTable
:dotnet version: 5.0.303