package common

import (
	"sync/atomic"
	"testing"

	"github.com/tidbcloud/pkgv2/gormutil"

	"github.com/tidbcloud/tidb-management-service/dedicated-global-service/pkg/config"
)

var globalConf atomic.Pointer[config.Config]

// Tests in this package will test service functions that interact with the schema.
// Third-party service dependencies are mocked and not tested.
func TestMain(m *testing.M) {
	var (
		c = &config.Config{
			MysqlConfig: gormutil.Config{
				User:     "root",
				Database: "local_test",
				Password: "password",
				LogLevel: "warn",
			},
			ServerConfig: config.ServerConfig{},
			BizConfig: config.BizConfig{
				ClusterQuota: config.ClusterQuota{
					TiKV:    90,
					TiDB:    300,
					TiFlash: 10,
				},
				InsufficientResourceTimeout: "20m",
			},
		}
	)

	globalConf.Store(c)

	m.Run()
}
