package listing

import (
	"errors"
	"testing"
)

func TestListingBindErrorMessage(t *testing.T) {
	tests := []struct {
		name string
		err  error
		want string
	}{
		{
			name: "哈夫币字段格式错误",
			err:  errors.New("json: cannot unmarshal number 197100000.1 into Go struct field CreateRequest.haf_coin_amount of type int64"),
			want: "哈夫币数量格式不正确，请重新填写哈夫币/M后再提交",
		},
		{
			name: "普通绑定错误",
			err:  errors.New("Key: 'CreateRequest.Title' Error:Field validation for 'Title' failed"),
			want: "发布信息不完整",
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := listingBindErrorMessage(tt.err); got != tt.want {
				t.Fatalf("listingBindErrorMessage() = %q, want %q", got, tt.want)
			}
		})
	}
}
