-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added additional time support and tests
- Loading branch information
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package coral_test | ||
|
||
import ( | ||
"coral-importer/common/coral" | ||
"testing" | ||
) | ||
|
||
func TestTimeUnmarshalJSON(t *testing.T) { | ||
var tm coral.Time | ||
|
||
inputs := []struct { | ||
name string | ||
value string | ||
}{ | ||
{name: "normal date time", value: `{ "$date": "2018-10-25T23:57:49.053Z" }`}, | ||
{name: "negative number long", value: `{ "$date": { "$numberLong": "-62075098782000" } }`}, | ||
} | ||
|
||
for _, input := range inputs { | ||
t.Run(input.name, func(t *testing.T) { | ||
if err := tm.UnmarshalJSON([]byte(input.value)); err != nil { | ||
t.Errorf("expected no error with input %s, got %v", input.value, err) | ||
} | ||
}) | ||
} | ||
} |