Skip to content

Commit

Permalink
test: add test for time.Time methods on dotnettime
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed May 6, 2024
1 parent 32bcba0 commit f00f26d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions parsing/dotnet_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}
}

Expand All @@ -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)
Expand All @@ -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)
})
}

0 comments on commit f00f26d

Please sign in to comment.