package integration_test

import (
	"net/http"
	"testing"

	"github.com/AlchemyTelcoSolutions/callisto-so-bff/integration_tests/fakes"
	suiteclient "github.com/AlchemyTelcoSolutions/callisto-so-bff/integration_tests/suite-client"
	"github.com/AlchemyTelcoSolutions/callisto-so-bff/internal/domain/model"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/suite"
)

type saleOrderProxySuite struct {
	suite.Suite
	ClientGenerator *suiteclient.ClientGenerator
}

func (s *saleOrderProxySuite) TestProxyPaths() {
	t := s.T()

	tests := []struct {
		name    string
		caseAPI string
		assert  func(t *testing.T, resp *model.ProxyResponse)
	}{
		{
			name:    "NOT_FOUNT",
			caseAPI: fakes.ProxyNotFound,
			assert: func(t *testing.T, resp *model.ProxyResponse) {
				assert.Equal(t, resp.StatusCode, http.StatusNotFound)
				assert.Equal(t, resp.BodyBytes, []byte(http.StatusText(http.StatusNotFound)))
			},
		},
		{
			name:    "PROXY_SUCCESS_MAP",
			caseAPI: fakes.ProxySuccess,
			assert: func(t *testing.T, resp *model.ProxyResponse) {
				assert.Equal(t, resp.StatusCode, http.StatusOK)
				assert.Equal(t, resp.BodyBytes, []byte(fakes.Success))
			},
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			cli := s.ClientGenerator.NewClient(t)
			resp := cli.ForwardProxy(test.caseAPI)
			test.assert(t, resp)
		})
	}
}
