package global_client_test

import (
	"encoding/json"
	"testing"

	"github.com/stretchr/testify/assert"
	global_client "github.com/tidbcloud/auto-deploy/internal/global-client"
)

func TestSeraialErrorResponse(t *testing.T) {
	str := `{
  "code": 123,
  "message": "string",
  "details": [
    {
      "@type": "string",
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    }
  ]
}`
	resp := global_client.ErrorResponse{}
	err := json.Unmarshal([]byte(str), &resp)
	assert.NoError(t, err)
	bytes, err := json.Marshal(resp)
	assert.NoError(t, err)
	resp2 := global_client.ErrorResponse{}
	err = json.Unmarshal(bytes, &resp2)
	assert.NoError(t, err)
	assert.Equal(t, resp, resp2)
}
