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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package config
import (
"reflect"
"testing"
"github.com/containers/libpod/libpod/define"
"github.com/containers/storage"
"github.com/stretchr/testify/assert"
)
func TestEmptyConfig(t *testing.T) {
// Make sure that we can read empty configs
config, err := readConfigFromFile("testdata/empty.conf", &Config{})
assert.NotNil(t, config)
assert.Nil(t, err)
}
func TestDefaultLibpodConf(t *testing.T) {
// Make sure that we can read the default libpod.conf
config, err := readConfigFromFile("testdata/libpod.conf", &Config{})
assert.NotNil(t, config)
assert.Nil(t, err)
}
func TestMergeEmptyAndDefaultMemoryConfig(t *testing.T) {
// Make sure that when we merge the default config into an empty one that we
// effectively get the default config.
defaultConfig, err := defaultConfigFromMemory()
assert.NotNil(t, defaultConfig)
assert.Nil(t, err)
defaultConfig.StateType = define.InvalidStateStore
defaultConfig.StorageConfig = storage.StoreOptions{}
emptyConfig, err := readConfigFromFile("testdata/empty.conf", defaultConfig)
assert.NotNil(t, emptyConfig)
assert.Nil(t, err)
equal := reflect.DeepEqual(emptyConfig, defaultConfig)
assert.True(t, equal)
}
func TestMergeEmptyAndLibpodConfig(t *testing.T) {
// Make sure that when we merge the default config into an empty one that we
// effectively get the default config.
libpodConfig, err := readConfigFromFile("testdata/libpod.conf", &Config{})
assert.NotNil(t, libpodConfig)
assert.Nil(t, err)
libpodConfig.StateType = define.InvalidStateStore
libpodConfig.StorageConfig = storage.StoreOptions{}
emptyConfig, err := readConfigFromFile("testdata/empty.conf", libpodConfig)
assert.NotNil(t, emptyConfig)
assert.Nil(t, err)
equal := reflect.DeepEqual(emptyConfig, libpodConfig)
assert.True(t, equal)
}
|