Add test for bad entries in storage.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
6e19a22428
commit
c2bc7b1643
|
|
@ -1,11 +1,14 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
|
@ -110,3 +113,14 @@ func TestGetRootlessStorageOpts2(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
assert.Equal(t, storageOpts.GraphRoot, expectedPath)
|
||||
}
|
||||
|
||||
func TestReloadConfigurationFile(t *testing.T) {
|
||||
content := bytes.NewBufferString("")
|
||||
logrus.SetOutput(content)
|
||||
var storageOpts StoreOptions
|
||||
ReloadConfigurationFile("./storage_broken.conf", &storageOpts)
|
||||
assert.Equal(t, storageOpts.RunRoot, "/run/containers/test")
|
||||
logrus.SetOutput(os.Stderr)
|
||||
|
||||
assert.Equal(t, strings.Contains(content.String(), "Failed to decode the keys [\\\"foo\\\" \\\"storage.options.graphroot\\\"] from \\\"./storage_broken.conf\\\".\""), true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# This file is is a TEST configuration file for all tools
|
||||
# that use the containers/storage library.
|
||||
# See man 5 containers-storage.conf for more information
|
||||
# The "container storage" table contains all of the server options.
|
||||
foo = "bar"
|
||||
|
||||
[storage]
|
||||
|
||||
# Default Storage Driver
|
||||
driver = ""
|
||||
|
||||
# Temporary storage location
|
||||
runroot = "/run/containers/test"
|
||||
|
||||
[storage.options]
|
||||
# Primary Read/Write location of container storage
|
||||
graphroot = "/var/lib/containers/storage"
|
||||
|
||||
Loading…
Reference in New Issue