From f00f26d4ccbee87fe91b8533ec1241bc7bf41ac8 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Mon, 6 May 2024 19:49:30 +0200 Subject: [PATCH] test: add test for time.Time methods on dotnettime --- parsing/dotnet_time_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/parsing/dotnet_time_test.go b/parsing/dotnet_time_test.go index ba919f3..24b4abd 100644 --- a/parsing/dotnet_time_test.go +++ b/parsing/dotnet_time_test.go @@ -37,8 +37,8 @@ func (suite *DotnetTimeUnitTestSuite) SetupSuite() { ` suite.expectedUnmarshaledJSON = TestUnmarshalObject{ Name: "tester", - Created: DotnetTime(suite.expectedDatetime), - Updated: DotnetTime(suite.expectedDatetime), + Created: DotnetTime{Time: suite.expectedDatetime}, + Updated: DotnetTime{Time: suite.expectedDatetime}, } } @@ -51,7 +51,7 @@ func (suite *DotnetTimeUnitTestSuite) TestUnmarshalJSON() { suite.Run("should unmarshal the dotnet timestring to DotnetTime object", func() { winTime := DotnetTime{} - expectedDotnetTime := DotnetTime(suite.expectedDatetime) + expectedDotnetTime := DotnetTime{Time: suite.expectedDatetime} err := winTime.UnmarshalJSON([]byte(suite.dotNetDatetime)) suite.NoError(err) suite.Equal(expectedDotnetTime, winTime) @@ -70,3 +70,12 @@ func (suite *DotnetTimeUnitTestSuite) TestUnmarshalJSON() { suite.Equal(suite.expectedUnmarshaledJSON, actualResult) }) } + +func (suite *DotnetTimeUnitTestSuite) TestTimeMethods() { + suite.Run("should be able to format dotnet time to RFC3389", func() { + dotnetTime := DotnetTime{Time: time.Date(2023, time.November, 30, 21, 25, 5, 0, time.UTC)} + actualResult := dotnetTime.Format(time.RFC3339) + expectedResult := "2023-11-30T21:25:05Z" + suite.Equal(expectedResult, actualResult) + }) +}