got: switch Date to int
This commit is contained in:
parent
e34a9e4cd8
commit
a2543d1984
2
got.go
2
got.go
@ -45,7 +45,7 @@ type Notification struct {
|
||||
ID string `json:"id"`
|
||||
Author Author `json:"author,omitempty"`
|
||||
Committer Committer `json:"committer"`
|
||||
Date string `json:"date"`
|
||||
Date int `json:"date"`
|
||||
ShortMessage string `json:"short_message"`
|
||||
Message string `json:"message"`
|
||||
Diffstat Diffstat `json:"diffstat,omitempty"`
|
||||
|
13
got_test.go
13
got_test.go
@ -1,19 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGotNotification(t *testing.T) {
|
||||
jsonStr := `{"notifications":[{"type":"commit", "short":false, "repo":"test-repo", "id":"34d7c970d4bd3a5832ecded86f2c28e83dbba2ba", "author":{ "full":"Flan Hacker <flan@openbsd.org>", "name":"Flan Hacker", "mail":"flan@openbsd.org", "user":"flan" }, "committer":{ "full":"Flan Hacker <flan@openbsd.org>", "name":"Flan Hacker", "mail":"flan@openbsd.org", "user":"flan" }, "date":"Thu Apr 18 16:47:40 2024 UTC", "short_message":"make changes", "message":"make changes\n", "diffstat":{ "files":[{ "action":"modified", "file":"alpha", "added":1, "removed":1 }], "total":{ "added":1, "removed":1 } }}]}`
|
||||
jsonData, err := os.ReadFile("test_body.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
nots := &GotNotifications{}
|
||||
dec := json.NewDecoder(strings.NewReader(jsonStr))
|
||||
err := dec.Decode(nots)
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(jsonData))
|
||||
err = dec.Decode(nots)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
"mail": "flan@openbsd.org",
|
||||
"user": "flan"
|
||||
},
|
||||
"date": "Thu Apr 18 16:47:40 2024 UTC",
|
||||
"date": 1714041300,
|
||||
"short_message": "make changes",
|
||||
"message": "make changes\n",
|
||||
"diffstat": {
|
||||
@ -52,7 +52,7 @@
|
||||
"mail": "flans@openbsd.org",
|
||||
"user": "flans"
|
||||
},
|
||||
"date": "Thu Apr 18 16:48:40 2024 UTC",
|
||||
"date": 1714041301,
|
||||
"short_message": "make more changes",
|
||||
"message": "make more changes\n",
|
||||
"diffstat": {
|
||||
@ -81,7 +81,7 @@
|
||||
"mail": "flans@openbsd.org",
|
||||
"user": "flans"
|
||||
},
|
||||
"date": "Thu Apr 19 16:48:40 2024 UTC",
|
||||
"date": 1714041302,
|
||||
"short_message": "revert changes",
|
||||
"message": "revert all the previous changes\n"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user