package handlers_test

import (
	"net/http"
	"os"
	"testing"

	"github.com/fiskerinc/cloud-services/services/gateway/handlers"

	"github.com/fiskerinc/cloud-services/pkg/httpclient/tester"
	"github.com/fiskerinc/cloud-services/pkg/testhelper"
	"github.com/fiskerinc/cloud-services/pkg/testrunner"
)

func TestDocsHandler(t *testing.T) {
	os.Setenv("DOCS", "/non-existent-folder")
	handler := handlers.DocsHandler()

	tests := []testrunner.TestCase{
		{
			Name: "Simple",
			HttpTestCase: &tester.HttpTestCase{
				Request:        testhelper.MakeTestRequest(http.MethodGet, "http://example.com/docs", nil),
				ExpectedStatus: http.StatusNotFound,
				ExpectedResponse: `404 page not found
`,
			},
		},
	}

	for _, test := range tests {
		if test.HttpTestCase != nil {
			w := test.HttpTestCase.Test(handler.ServeHTTP)
			test.HttpTestCase.ValidateHttp(t, test.Name, w)
		}
	}
}
