Files
go-onlyoffice/http_test.go
T
eSliderandCursor 0ed2d9b0f5 feat(office): users admin UI, table rendering, and user save fixes
Add Users list/detail with ACL toggles and library people update/status APIs.
Fix project table layout and ANSI-safe cell rendering, and decode array
responses from people/status so saves no longer fail on JSON unmarshal.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 11:07:22 +01:00

51 lines
1.1 KiB
Go

package onlyoffice
import (
"encoding/json"
"testing"
)
func TestUnmarshalResponseObjectMap(t *testing.T) {
raw := json.RawMessage(`{"response":{"id":"1","isAdmin":true}}`)
out, err := unmarshalResponseObject(raw)
if err != nil {
t.Fatal(err)
}
if out["id"] != "1" || out["isAdmin"] != true {
t.Fatalf("unexpected map: %#v", out)
}
}
func TestUnmarshalResponseObjectArray(t *testing.T) {
raw := json.RawMessage(`{"response":[{"id":"a"},{"id":"b"}]}`)
out, err := unmarshalResponseObject(raw)
if err != nil {
t.Fatal(err)
}
if out["id"] != "a" {
t.Fatalf("expected first array element, got %#v", out)
}
}
func TestUnmarshalResponseObjectEmptyArray(t *testing.T) {
raw := json.RawMessage(`{"response":[]}`)
out, err := unmarshalResponseObject(raw)
if err != nil {
t.Fatal(err)
}
if out != nil {
t.Fatalf("expected nil for empty array, got %#v", out)
}
}
func TestUnmarshalResponseObjectNull(t *testing.T) {
raw := json.RawMessage(`{"response":null}`)
out, err := unmarshalResponseObject(raw)
if err != nil {
t.Fatal(err)
}
if out != nil {
t.Fatalf("expected nil, got %#v", out)
}
}