mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] Mastodon api fixups (#617)
* don't omitempty on description * don't omitempty on any fields * add ms to timestamp format * don't omitempty on text_url * rearrange attachment fields a bit * just give URL again as attachment text url * update tests * fix accidental replace
This commit is contained in:
@@ -21,7 +21,7 @@ package util
|
||||
import "time"
|
||||
|
||||
// ISO8601 is a formatter for serializing times that forces ISO8601 behavior.
|
||||
const ISO8601 = "2006-01-02T15:04:05Z"
|
||||
const ISO8601 = "2006-01-02T15:04:05.00Z"
|
||||
|
||||
// FormatISO8601 converts the given time to UTC and then formats it
|
||||
// using the ISO8601 const, which the Mastodon API is able to understand.
|
||||
|
@@ -33,19 +33,19 @@ type TimeSuite struct {
|
||||
func (suite *TimeSuite) TestISO8601Format1() {
|
||||
testTime := testrig.TimeMustParse("2022-05-17T13:10:59Z")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2022-05-17T13:10:59Z", testTimeString)
|
||||
suite.Equal("2022-05-17T13:10:59.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func (suite *TimeSuite) TestISO8601Format2() {
|
||||
testTime := testrig.TimeMustParse("2022-05-09T07:34:35+02:00")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2022-05-09T05:34:35Z", testTimeString)
|
||||
suite.Equal("2022-05-09T05:34:35.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func (suite *TimeSuite) TestISO8601Format3() {
|
||||
testTime := testrig.TimeMustParse("2021-10-04T10:52:36+02:00")
|
||||
testTimeString := util.FormatISO8601(testTime)
|
||||
suite.Equal("2021-10-04T08:52:36Z", testTimeString)
|
||||
suite.Equal("2021-10-04T08:52:36.00Z", testTimeString)
|
||||
}
|
||||
|
||||
func TestTimeSuite(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user