kaiyan/ingest/wire_test.go
2025-04-06 09:20:32 -04:00

46 lines
755 B
Go

package ingest_test
import (
"testing"
"github.com/go-json-experiment/json"
"git.sunturtle.xyz/zephyr/kaiyan/ingest"
)
func TestNullableString(t *testing.T) {
cases := []struct {
name string
json string
want ingest.NullableString
}{
{
name: "null",
json: "null",
want: "",
},
{
name: "simple",
json: `"bocchi"`,
want: "bocchi",
},
{
name: "quotes",
json: `"\"bocchi\""`,
want: `"bocchi"`,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
var got ingest.NullableString
err := json.Unmarshal([]byte(c.json), &got)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if got != c.want {
t.Errorf("wrong result: want %q, got %q", c.want, got)
}
})
}
}