summaryrefslogtreecommitdiff
path: root/pkg/hooks/0.1.0/hook_test.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-06-16 16:21:43 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-06-17 05:39:57 -0400
commita36bc1526652341126a180a304d99777378375ff (patch)
treeb259937f964aaa063389cba6d595f7a907b881e5 /pkg/hooks/0.1.0/hook_test.go
parent4fb0f56063de13af53128be9da81027d988516be (diff)
downloadpodman-a36bc1526652341126a180a304d99777378375ff.tar.gz
podman-a36bc1526652341126a180a304d99777378375ff.tar.bz2
podman-a36bc1526652341126a180a304d99777378375ff.zip
Fix handling of old oci hooks
Podman is blowing up with oci-umount hook, because it was never rewritten to support the v1.0.0 value. This PR adds support for the older version and cleans up the hook handling. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/hooks/0.1.0/hook_test.go')
-rw-r--r--pkg/hooks/0.1.0/hook_test.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/pkg/hooks/0.1.0/hook_test.go b/pkg/hooks/0.1.0/hook_test.go
index 66774075e..11881ca0b 100644
--- a/pkg/hooks/0.1.0/hook_test.go
+++ b/pkg/hooks/0.1.0/hook_test.go
@@ -9,7 +9,7 @@ import (
)
func TestGood(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"cmds\": [\"sh\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"cmds\": [\"sh\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -27,7 +27,7 @@ func TestGood(t *testing.T) {
}
func TestInvalidJSON(t *testing.T) {
- _, err := read([]byte("{"))
+ _, err := Read([]byte("{"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -35,7 +35,7 @@ func TestInvalidJSON(t *testing.T) {
}
func TestArguments(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"arguments\": [\"d\", \"e\"], \"stages\": [\"prestart\"], \"cmds\": [\"sh\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"arguments\": [\"d\", \"e\"], \"stages\": [\"prestart\"], \"cmds\": [\"sh\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -54,7 +54,7 @@ func TestArguments(t *testing.T) {
}
func TestEmptyObject(t *testing.T) {
- _, err := read([]byte("{}"))
+ _, err := Read([]byte("{}"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -62,7 +62,7 @@ func TestEmptyObject(t *testing.T) {
}
func TestNoStages(t *testing.T) {
- _, err := read([]byte("{\"hook\": \"/a/b/c\"}"))
+ _, err := Read([]byte("{\"hook\": \"/a/b/c\"}"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -70,7 +70,7 @@ func TestNoStages(t *testing.T) {
}
func TestStage(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -85,7 +85,7 @@ func TestStage(t *testing.T) {
}
func TestStagesAndStage(t *testing.T) {
- _, err := read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"stage\": [\"prestart\"]}"))
+ _, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"stage\": [\"prestart\"]}"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -93,7 +93,7 @@ func TestStagesAndStage(t *testing.T) {
}
func TestCmd(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"cmd\": [\"sh\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"cmd\": [\"sh\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -111,7 +111,7 @@ func TestCmd(t *testing.T) {
}
func TestCmdsAndCmd(t *testing.T) {
- _, err := read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"cmds\": [\"sh\"], \"cmd\": [\"true\"]}"))
+ _, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"cmds\": [\"sh\"], \"cmd\": [\"true\"]}"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -119,7 +119,7 @@ func TestCmdsAndCmd(t *testing.T) {
}
func TestAnnotations(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"annotations\": [\"a\", \"b\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"annotations\": [\"a\", \"b\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -137,7 +137,7 @@ func TestAnnotations(t *testing.T) {
}
func TestAnnotation(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"annotation\": [\"a\", \"b\"]}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"annotation\": [\"a\", \"b\"]}"))
if err != nil {
t.Fatal(err)
}
@@ -155,7 +155,7 @@ func TestAnnotation(t *testing.T) {
}
func TestAnnotationsAndAnnotation(t *testing.T) {
- _, err := read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"annotations\": [\"a\"], \"annotation\": [\"b\"]}"))
+ _, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stages\": [\"prestart\"], \"annotations\": [\"a\"], \"annotation\": [\"b\"]}"))
if err == nil {
t.Fatal("unexpected success")
}
@@ -163,7 +163,7 @@ func TestAnnotationsAndAnnotation(t *testing.T) {
}
func TestHasBindMounts(t *testing.T) {
- hook, err := read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"hasbindmounts\": true}"))
+ hook, err := Read([]byte("{\"hook\": \"/a/b/c\", \"stage\": [\"prestart\"], \"hasbindmounts\": true}"))
if err != nil {
t.Fatal(err)
}