|
1 | 1 | package config_test |
2 | 2 |
|
3 | | -// |
4 | | -//func TestConfiguration_init_ShouldCorrectlyInitializeConfiguration(t *testing.T) { |
5 | | -// t.Parallel() |
6 | | -// |
7 | | -// //setup |
8 | | -// defer utils.UnsetEnv("PACKAGR_")() |
9 | | -// |
10 | | -// //test |
11 | | -// testConfig, _ := config.Create() |
12 | | -// |
13 | | -// //assert |
14 | | -// require.Equal(t, "generic", testConfig.GetString(config.PACKAGR_PACKAGE_TYPE), "should populate package_type with generic default") |
15 | | -// require.Equal(t, "default", testConfig.GetString(config.PACKAGR_SCM), "should populate scm with default") |
16 | | -// require.Equal(t, "patch", testConfig.GetString(config.PACKAGR_VERSION_BUMP_TYPE), "should populate runner with default") |
17 | | -//} |
| 3 | +import ( |
| 4 | + "github.com/analogj/go-util/utils" |
| 5 | + "github.com/packagrio/releasr/pkg/config" |
| 6 | + "github.com/stretchr/testify/require" |
| 7 | + "path" |
| 8 | + "testing" |
| 9 | +) |
| 10 | + |
| 11 | +func TestConfiguration_init_ShouldCorrectlyInitializeConfiguration(t *testing.T) { |
| 12 | + //setup |
| 13 | + defer utils.UnsetEnv("PACKAGR_")() |
| 14 | + |
| 15 | + //test |
| 16 | + testConfig, _ := config.Create() |
| 17 | + |
| 18 | + //assert |
| 19 | + require.Equal(t, "generic", testConfig.GetString(config.PACKAGR_PACKAGE_TYPE), "should populate package_type with generic default") |
| 20 | + require.Equal(t, "default", testConfig.GetString(config.PACKAGR_SCM), "should populate scm with default") |
| 21 | + require.Equal(t, "Automated packaging of release by Packagr", testConfig.GetString(config.PACKAGR_VERSION_BUMP_MESSAGE), "should populate bump message with default") |
| 22 | +} |
| 23 | + |
| 24 | +func TestConfiguration_ReadConfig(t *testing.T) { |
| 25 | + //setup |
| 26 | + defer utils.UnsetEnv("PACKAGR_")() |
| 27 | + |
| 28 | + testConfig, _ := config.Create() |
| 29 | + testConfig.SetDefault(config.PACKAGR_PACKAGE_TYPE, "generic") |
| 30 | + testConfig.SetDefault(config.PACKAGR_SCM, "default") |
| 31 | + |
| 32 | + //test |
| 33 | + err := testConfig.ReadConfig(path.Join("testdata", "simple_overrides.yml")) |
| 34 | + |
| 35 | + //assert |
| 36 | + require.NoErrorf(t, err, "No error") |
| 37 | + require.Equal(t, "golang", testConfig.GetString(config.PACKAGR_PACKAGE_TYPE), "should populate Package Type from overrides config file") |
| 38 | + require.Equal(t, "github", testConfig.GetString(config.PACKAGR_SCM), "should populate SCM from overrides config file") |
| 39 | + |
| 40 | +} |
| 41 | + |
| 42 | + |
18 | 43 | // |
19 | 44 | //func TestConfiguration_init_EnvVariablesShouldLoadProperly(t *testing.T) { |
20 | 45 | // //setup |
|
0 commit comments