mcchunkie/got_test.go

28 lines
412 B
Go
Raw Normal View History

2024-04-18 09:10:54 -06:00
package main
import (
2024-04-25 07:14:45 -06:00
"bytes"
2024-04-18 09:10:54 -06:00
"encoding/json"
"fmt"
2024-04-25 07:14:45 -06:00
"os"
2024-04-18 09:10:54 -06:00
"testing"
)
func TestGotNotification(t *testing.T) {
2024-04-25 07:14:45 -06:00
jsonData, err := os.ReadFile("test_body.json")
if err != nil {
t.Fatal(err)
}
2024-04-18 09:10:54 -06:00
nots := &GotNotifications{}
2024-04-25 07:14:45 -06:00
dec := json.NewDecoder(bytes.NewReader(jsonData))
err = dec.Decode(nots)
2024-04-18 09:10:54 -06:00
if err != nil {
t.Fatal(err)
}
for _, n := range nots.Notifications {
fmt.Println(n.String())
}
}