package api_test

import (
	"log"
	"net/http"
	"os"
	"testing"

	"github.com/jvikstedt/alarmy/api"
	"github.com/jvikstedt/alarmy/store"
)

var handler http.Handler
var mockStore *store.MockStore

func TestMain(m *testing.M) {
	setup()
	retCode := m.Run()
	os.Exit(retCode)
}

func setup() {
	mockStore = &store.MockStore{}
	store := store.Store{
		ProjectStore: mockStore,
	}

	logger := log.New(os.Stdout, "", log.LstdFlags)
	api := api.NewApi(store, logger)

	var err error
	handler, err = api.Handler()
	if err != nil {
		panic(err)
	}
}

package api_test

import (
	"bytes"
	"log"
	"net/http"
	"os"
	"testing"

	"github.com/jvikstedt/alarmy/api"
	"github.com/jvikstedt/alarmy/store"
)

var handler http.Handler
var mockStore *store.MockStore
var logs = &bytes.Buffer{}

func TestMain(m *testing.M) {
	setup()
	retCode := m.Run()
	os.Exit(retCode)
}

func setup() {
	mockStore = &store.MockStore{}
	store := store.Store{
		ProjectStore: mockStore,
	}

	logger := log.New(logs, "", log.LstdFlags)
	api := api.NewApi(store, logger)

	var err error
	handler, err = api.Handler()
	if err != nil {
		panic(err)
	}
}

Write test logs to a buffer, so it can be used for testing and cleaner test output
Write test logs to a buffer, so it can be used for testing and cleaner
test output
