package hostorg

import (
	"encoding/json"
	"testing"
)

func TestFlexibleInt64AcceptsStringAndNumber(t *testing.T) {
	t.Parallel()
	cases := []struct {
		name string
		body string
		want int64
	}{
		{name: "string", body: `{"targetUserId":"323096761415507968"}`, want: 323096761415507968},
		{name: "number", body: `{"targetUserId":323096761415507968}`, want: 323096761415507968},
	}
	for _, tc := range cases {
		tc := tc
		t.Run(tc.name, func(t *testing.T) {
			t.Parallel()
			var req createBDLeaderRequest
			if err := json.Unmarshal([]byte(tc.body), &req); err != nil {
				t.Fatalf("unmarshal request: %v", err)
			}
			if got := req.TargetUserID.Int64(); got != tc.want {
				t.Fatalf("target user id = %d, want %d", got, tc.want)
			}
		})
	}
}
