diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-26 10:25:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-26 10:25:05 +0200 |
commit | 4674d00f46380f38532ebf32cd632579b47773bb (patch) | |
tree | 25c7482dff6fc8fe6502073c8a9c045a525c8dfe /pkg/hooks/monitor_test.go | |
parent | dff82d940e50c50c9f15a0371942662ccaaaae43 (diff) | |
parent | d6ea4b4139c5e890acdb99cbcc303c160031a780 (diff) | |
download | podman-4674d00f46380f38532ebf32cd632579b47773bb.tar.gz podman-4674d00f46380f38532ebf32cd632579b47773bb.tar.bz2 podman-4674d00f46380f38532ebf32cd632579b47773bb.zip |
Merge pull request #3580 from samc24/hook
Improved hooks monitoring
Diffstat (limited to 'pkg/hooks/monitor_test.go')
-rw-r--r-- | pkg/hooks/monitor_test.go | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/pkg/hooks/monitor_test.go b/pkg/hooks/monitor_test.go index 31d7f9e39..dc67eaf83 100644 --- a/pkg/hooks/monitor_test.go +++ b/pkg/hooks/monitor_test.go @@ -226,7 +226,28 @@ func TestMonitorTwoDirGood(t *testing.T) { assert.Equal(t, primaryInjected, config.Hooks) // masked by primary }) - t.Run("bad-primary-addition", func(t *testing.T) { + primaryPath2 := filepath.Join(primaryDir, "0a.json") //0a because it will be before a.json alphabetically + + t.Run("bad-primary-new-addition", func(t *testing.T) { + err = ioutil.WriteFile(primaryPath2, []byte("{\"version\": \"-1\"}"), 0644) + if err != nil { + t.Fatal(err) + } + + time.Sleep(100 * time.Millisecond) // wait for monitor to notice + + config := &rspec.Spec{} + fmt.Println("expected: ", config.Hooks) + expected := primaryInjected // 0a.json is bad, a.json is still good + _, err = manager.Hooks(config, map[string]string{}, false) + fmt.Println("actual: ", config.Hooks) + if err != nil { + t.Fatal(err) + } + assert.Equal(t, expected, config.Hooks) + }) + + t.Run("bad-primary-same-addition", func(t *testing.T) { err = ioutil.WriteFile(primaryPath, []byte("{\"version\": \"-1\"}"), 0644) if err != nil { t.Fatal(err) @@ -235,7 +256,7 @@ func TestMonitorTwoDirGood(t *testing.T) { time.Sleep(100 * time.Millisecond) // wait for monitor to notice config := &rspec.Spec{} - expected := config.Hooks + expected := fallbackInjected _, err = manager.Hooks(config, map[string]string{}, false) if err != nil { t.Fatal(err) |