package bdd

import (
	"dance-lessons-coach/pkg/bdd/steps"
	"dance-lessons-coach/pkg/bdd/testserver"

	"github.com/cucumber/godog"
)

var sharedServer *testserver.Server

func InitializeTestSuite(ctx *godog.TestSuiteContext) {
	ctx.BeforeSuite(func() {
		sharedServer = testserver.NewServer()
		if err := sharedServer.Start(); err != nil {
			panic(err)
		}
	})

	ctx.AfterSuite(func() {
		if sharedServer != nil {
			sharedServer.Stop()
		}
	})
}

func InitializeScenario(ctx *godog.ScenarioContext) {
	client := testserver.NewClient(sharedServer)
	steps.InitializeAllSteps(ctx, client)
}
