package api_test

import (
	"os"
	"testing"
	"time"

	api "git.nochill.in/nochill/hiling_go/api"
	db "git.nochill.in/nochill/hiling_go/db/sqlc"
	"git.nochill.in/nochill/hiling_go/util"
	"github.com/gin-gonic/gin"
	_ "github.com/lib/pq"
	"github.com/stretchr/testify/require"
)

func newTestServer(t *testing.T, store db.Store) *api.Server {
	config := util.Config{
		TokenSymmetricKey: util.RandomString(32),
		TokenDuration:     time.Minute,
	}

	server, err := api.NewServer(config, store)
	require.NoError(t, err)

	return server
}

func TestMain(m *testing.M) {
	gin.SetMode(gin.TestMode)

	os.Exit(m.Run())
}