aboutsummaryrefslogtreecommitdiffstats
path: root/internal/configloader/configloader_windows_test.go
blob: 1ba6c51ca0c426b7e5a6383fa4718ad9fd1d7650 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//go:build windows

package configloader_test

import (
	"os"
	"path/filepath"
	"testing"

	"github.com/eugenetriguba/bolt/internal/bolttest"
	"github.com/eugenetriguba/bolt/internal/configloader"
	"github.com/eugenetriguba/checkmate/assert"
)

func TestNewConfigWindowsSearchesToRootFilePath(t *testing.T) {
	expectedCfg := configloader.Config{
		Migrations: configloader.MigrationsConfig{
			DirectoryPath: "differentmigrationsdir",
			VersionStyle:  configloader.VersionStyleSequential,
		},
	}
	configPath := filepath.Join(os.Getenv("SystemDrive"), "bolt.toml")
	bolttest.CreateConfigFile(t, &expectedCfg, configPath)
	assert.Nil(t, err)

	homedir, err := os.UserHomeDir()
	assert.Nil(t, err)
	bolttest.ChangeCwd(t, homedir)

	cfg, err := configloader.NewConfig()
	assert.Nil(t, err)

	assert.DeepEqual(t, *cfg, expectedCfg)
}