<commit_before>package api

import (
	"testing"

	"gitlab.com/faststack/machinestack/scheduler"

	"os"

	jwt "github.com/dgrijalva/jwt-go"
	"github.com/go-pg/pg"
)

var (
	testToken = jwt.Token{Claims: jwt.MapClaims{
		"id":            1,
		"machine_quota": map[string]int{"instances": 10, "cpu": 1, "ram": 1},
	}}
	testScheduler, _ = scheduler.NewMockScheduler(nil)
	mockScheduler    = testScheduler.(*scheduler.MockScheduler)
	testDB           *pg.DB
	testHandler      *Handler
)

func TestMain(m *testing.M) {
	testDB = pg.Connect(&pg.Options{
		Addr:     os.Getenv("POSTGRES_ADDR"),
		User:     os.Getenv("POSTGRES_USER"),
		Password: os.Getenv("POSTGRES_PASSWORD"),
		Database: os.Getenv("POSTGRES_DB"),
	})

	if _, err := testDB.Query(nil, "TRUNCATE TABLE machines;"); err != nil {
		panic(err)
	}

	testHandler = &Handler{
		DB:           testDB,
		Scheduler:    testScheduler,
		AllowOrigins: []string{},
		JWTSecret:    []byte("foobar"),
	}

	retCode := m.Run()

	testDB.Close()
	os.Exit(retCode)
}
<commit_msg>create table<commit_after>package api

import (
	"testing"

	"gitlab.com/faststack/machinestack/model"
	"gitlab.com/faststack/machinestack/scheduler"

	"os"

	jwt "github.com/dgrijalva/jwt-go"
	"github.com/go-pg/pg"
	"github.com/go-pg/pg/orm"
)

var (
	testToken = jwt.Token{Claims: jwt.MapClaims{
		"id":            1,
		"machine_quota": map[string]int{"instances": 10, "cpu": 1, "ram": 1},
	}}
	testScheduler, _ = scheduler.NewMockScheduler(nil)
	mockScheduler    = testScheduler.(*scheduler.MockScheduler)
	testDB           *pg.DB
	testHandler      *Handler
)

func TestMain(m *testing.M) {
	testDB = pg.Connect(&pg.Options{
		Addr:     os.Getenv("POSTGRES_ADDR"),
		User:     os.Getenv("POSTGRES_USER"),
		Password: os.Getenv("POSTGRES_PASSWORD"),
		Database: os.Getenv("POSTGRES_DB"),
	})

	testDB.CreateTable(&model.Machine{}, &orm.CreateTableOptions{
		Temp: true,
	})

	testHandler = &Handler{
		DB:           testDB,
		Scheduler:    testScheduler,
		AllowOrigins: []string{},
		JWTSecret:    []byte("foobar"),
	}

	retCode := m.Run()

	testDB.Close()
	os.Exit(retCode)
}

{'fraction_non_alphanumeric': 0.16285714285714287, 'fraction_numerical': 0.004761904761904762, 'mean_word_length': 3.668888888888889, 'pattern_counts': {'":': 10, '<': 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': '1724292', 'n_tokens_mistral': 885, 'n_tokens_neox': 835, 'n_words': 130}