package tests

import (
	"flag"
	"os"
	"testing"

	"github.com/onsi/ginkgo/v2"
	"github.com/onsi/gomega"
	"github.com/spf13/pflag"
	"github.com/tidbcloud/aws-shared-provider/tests/framework"
)

func handleFlags() {
	framework.RegisterFlags(pflag.CommandLine)
	framework.CopyGoFlags(pflag.CommandLine, flag.CommandLine)

	// mark default flag parsed
	_ = flag.CommandLine.Parse(nil)
	pflag.Parse()
}

func TestMain(m *testing.M) {
	handleFlags()

	os.Exit(m.Run())
}

func TestE2E(t *testing.T) {
	gomega.RegisterFailHandler(ginkgo.Fail)
	framework.RunSpecs(t, "E2E Suite")
}
