summaryrefslogtreecommitdiff
path: root/libpod/runtime_img_test.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-11-05 06:43:20 -0500
committerGitHub <noreply@github.com>2017-11-05 06:43:20 -0500
commitb06190e0da66f45cbe6a44d79065fabcd00ea19c (patch)
treee50aa13cd31b63d797cabe4b9157599bf2f36898 /libpod/runtime_img_test.go
parent098389dc3e7bbba7c266ad24c909f3a5422e2908 (diff)
parent0026075d59b5e6e90786ed21825ac43d4f59fa5a (diff)
downloadpodman-b06190e0da66f45cbe6a44d79065fabcd00ea19c.tar.gz
podman-b06190e0da66f45cbe6a44d79065fabcd00ea19c.tar.bz2
podman-b06190e0da66f45cbe6a44d79065fabcd00ea19c.zip
Merge pull request #8 from baude/clicontext
Clicontext
Diffstat (limited to 'libpod/runtime_img_test.go')
-rw-r--r--libpod/runtime_img_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/libpod/runtime_img_test.go b/libpod/runtime_img_test.go
new file mode 100644
index 000000000..f7f7128a4
--- /dev/null
+++ b/libpod/runtime_img_test.go
@@ -0,0 +1,54 @@
+package libpod
+
+import (
+ "io/ioutil"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+var (
+ registry = `[registries.search]
+registries = ['one']
+
+[registries.insecure]
+registries = ['two']`
+)
+
+func createTmpFile(content []byte) (string, error) {
+ tmpfile, err := ioutil.TempFile(os.TempDir(), "unittest")
+ if err != nil {
+ return "", err
+ }
+
+ if _, err := tmpfile.Write(content); err != nil {
+ return "", err
+
+ }
+ if err := tmpfile.Close(); err != nil {
+ return "", err
+ }
+ return tmpfile.Name(), nil
+}
+
+func TestGetRegistries(t *testing.T) {
+ registryPath, err := createTmpFile([]byte(registry))
+ assert.NoError(t, err)
+ defer os.Remove(registryPath)
+ os.Setenv("REGISTRIES_CONFIG_PATH", registryPath)
+ registries, err := GetRegistries()
+ assert.NoError(t, err)
+ assert.True(t, reflect.DeepEqual(registries, []string{"one"}))
+}
+
+func TestGetInsecureRegistries(t *testing.T) {
+ registryPath, err := createTmpFile([]byte(registry))
+ assert.NoError(t, err)
+ os.Setenv("REGISTRIES_CONFIG_PATH", registryPath)
+ defer os.Remove(registryPath)
+ registries, err := GetInsecureRegistries()
+ assert.NoError(t, err)
+ assert.True(t, reflect.DeepEqual(registries, []string{"two"}))
+}