<commit_before>package index_test

import (
	"errors"
	"net/http"
	"net/http/httptest"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/pivotal-golang/lager/lagertest"

	"github.com/concourse/atc"
	"github.com/concourse/atc/db"
	dbfakes "github.com/concourse/atc/db/fakes"
	enginefakes "github.com/concourse/atc/engine/fakes"
	pipelinefakes "github.com/concourse/atc/pipelines/fakes"
	webfakes "github.com/concourse/atc/web/fakes"

	"github.com/concourse/atc/auth"
	"github.com/concourse/atc/web"
)

var _ = Describe("Handler", func() {
	var pipelineDBFactory *dbfakes.FakePipelineDBFactory
	var handler http.Handler

	BeforeEach(func() {
		logger := lagertest.NewTestLogger("web")
		radarSchedulerFactory := new(pipelinefakes.FakeRadarSchedulerFactory)
		db := new(webfakes.FakeWebDB)
		pipelineDBFactory = new(dbfakes.FakePipelineDBFactory)
		configDB := new(dbfakes.FakeConfigDB)
		engine := new(enginefakes.FakeEngine)

		var err error
		handler, err = web.NewHandler(
			logger,
			true,
			nil,
			nil,
			auth.NoopValidator{},
			radarSchedulerFactory,
			db,
			pipelineDBFactory,
			configDB,
			"templatefixtures",
			"../public",
			engine,
		)
		Expect(err).NotTo(HaveOccurred())
	})

	var recorder *httptest.ResponseRecorder

	JustBeforeEach(func() {
		recorder = httptest.NewRecorder()
		req, err := http.NewRequest("GET", "http://concourse.example.com/", nil)
		Expect(err).NotTo(HaveOccurred())

		handler.ServeHTTP(recorder, req)
	})

	Context("when the pipeline lookup fails", func() {
		Context("when there is an unexpected error", func() {
			BeforeEach(func() {
				pipelineDBFactory.BuildDefaultReturns(nil, false, errors.New("nope"))<commit_msg>fix constructor in web test<commit_after>package index_test

import (
	"errors"
	"net/http"
	"net/http/httptest"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/pivotal-golang/lager/lagertest"

	"github.com/concourse/atc"
	"github.com/concourse/atc/db"
	dbfakes "github.com/concourse/atc/db/fakes"
	enginefakes "github.com/concourse/atc/engine/fakes"
	pipelinefakes "github.com/concourse/atc/pipelines/fakes"
	webfakes "github.com/concourse/atc/web/fakes"

	"github.com/concourse/atc/auth"
	"github.com/concourse/atc/web"
)

var _ = Describe("Handler", func() {
	var pipelineDBFactory *dbfakes.FakePipelineDBFactory
	var handler http.Handler

	BeforeEach(func() {
		logger := lagertest.NewTestLogger("web")
		radarSchedulerFactory := new(pipelinefakes.FakeRadarSchedulerFactory)
		db := new(webfakes.FakeWebDB)
		pipelineDBFactory = new(dbfakes.FakePipelineDBFactory)
		configDB := new(dbfakes.FakeConfigDB)
		engine := new(enginefakes.FakeEngine)

		var err error
		handler, err = web.NewHandler(
			logger,
			true,
			nil,
			auth.NoopValidator{},
			radarSchedulerFactory,
			db,
			pipelineDBFactory,
			configDB,
			"templatefixtures",
			"../public",
			engine,
		)
		Expect(err).NotTo(HaveOccurred())
	})

	var recorder *httptest.ResponseRecorder

	JustBeforeEach(func() {
		recorder = httptest.NewRecorder()
		req, err := http.NewRequest("GET", "http://concourse.example.com/", nil)
		Expect(err).NotTo(HaveOccurred())

		handler.ServeHTTP(recorder, req)
	})

	Context("when the pipeline lookup fails", func() {
		Context("when there is an unexpected error", func() {
			BeforeEach(func() {
				pipelineDBFactory.BuildDefaultReturns(nil, false, errors.New("nope"))
{'fraction_non_alphanumeric': 0.13851151801535735, 'fraction_numerical': 0.0, 'mean_word_length': 4.635607321131448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4972059', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1238, 'n_words': 188}