30 lines
702 B
Go
30 lines
702 B
Go
package agent
|
|
|
|
import "testing"
|
|
|
|
func TestParseColdSummariesJSON(t *testing.T) {
|
|
got, err := parseColdSummaries(`{"0":"summary","1":"another"}`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got["0"] != "summary" || got["1"] != "another" {
|
|
t.Fatalf("unexpected summaries: %#v", got)
|
|
}
|
|
}
|
|
|
|
func TestParseColdSummariesFencedJSON(t *testing.T) {
|
|
got, err := parseColdSummaries("```json\n{\"0\":\"summary\"}\n```")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got["0"] != "summary" {
|
|
t.Fatalf("unexpected summaries: %#v", got)
|
|
}
|
|
}
|
|
|
|
func TestParseColdSummariesRejectsInvalidJSON(t *testing.T) {
|
|
if _, err := parseColdSummaries("not JSON"); err == nil {
|
|
t.Fatal("parseColdSummaries accepted invalid JSON")
|
|
}
|
|
}
|