summaryrefslogtreecommitdiff
path: root/pkg/hooks/1.0.0/when_test.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-08-21 09:23:28 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-22 11:48:43 +0000
commitb4420e22fc838fd2bd9712d476656ed6e891d4c8 (patch)
treeb016d1b1c00506d715e3c6238dad5239b11f5f21 /pkg/hooks/1.0.0/when_test.go
parent149481a57184becf3e9be329d253602654414118 (diff)
downloadpodman-b4420e22fc838fd2bd9712d476656ed6e891d4c8.tar.gz
podman-b4420e22fc838fd2bd9712d476656ed6e891d4c8.tar.bz2
podman-b4420e22fc838fd2bd9712d476656ed6e891d4c8.zip
Fix a bug with hook ALWAYS matching with a process
When a non-nil process was used and a hook was set to match always, this would not actually match. Fix this. Fixes: #1308 Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1311 Approved by: rhatdan
Diffstat (limited to 'pkg/hooks/1.0.0/when_test.go')
-rw-r--r--pkg/hooks/1.0.0/when_test.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/pkg/hooks/1.0.0/when_test.go b/pkg/hooks/1.0.0/when_test.go
index 61e725c8c..7187b297b 100644
--- a/pkg/hooks/1.0.0/when_test.go
+++ b/pkg/hooks/1.0.0/when_test.go
@@ -24,16 +24,22 @@ func TestNoMatch(t *testing.T) {
func TestAlways(t *testing.T) {
config := &rspec.Spec{}
+ processStruct := &rspec.Process{
+ Args: []string{"/bin/sh", "a", "b"},
+ }
for _, always := range []bool{true, false} {
for _, or := range []bool{true, false} {
- t.Run(fmt.Sprintf("always %t, or %t", always, or), func(t *testing.T) {
- when := When{Always: &always, Or: or}
- match, err := when.Match(config, map[string]string{}, false)
- if err != nil {
- t.Fatal(err)
- }
- assert.Equal(t, always, match)
- })
+ for _, process := range []*rspec.Process{processStruct, nil} {
+ t.Run(fmt.Sprintf("always %t, or %t, has process %t", always, or, (process != nil)), func(t *testing.T) {
+ config.Process = process
+ when := When{Always: &always, Or: or}
+ match, err := when.Match(config, map[string]string{}, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assert.Equal(t, always, match)
+ })
+ }
}
}
}