fossteams-api/pkg/util/json_test.go
copilot-swe-agent[bot] 631c192034
feat: add Bun JS port
2026-06-04 13:44:27 +00:00

36 lines
873 B
Go

package util
import (
"io"
"net/http"
"strings"
"testing"
)
func TestGetJSONWithoutDebugSave(t *testing.T) {
reader, err := GetJSON(&http.Response{Body: io.NopCloser(strings.NewReader(`{"ok":true}`))}, false)
if err != nil {
t.Fatalf("expected body reader: %v", err)
}
body, err := io.ReadAll(reader)
if err != nil {
t.Fatalf("unable to read body: %v", err)
}
if string(body) != `{"ok":true}` {
t.Fatalf("unexpected body: %s", string(body))
}
}
func TestGetJSONWithDebugSave(t *testing.T) {
reader, err := GetJSON(&http.Response{Body: io.NopCloser(strings.NewReader(`{"ok":true}`))}, true)
if err != nil {
t.Fatalf("expected body reader: %v", err)
}
body, err := io.ReadAll(reader)
if err != nil {
t.Fatalf("unable to read debug body: %v", err)
}
if string(body) != `{"ok":true}` {
t.Fatalf("unexpected debug body: %s", string(body))
}
}