|
1 | | -// Copyright (c) 2021-2025, R.I. Pienaar and the Choria Project contributors |
| 1 | +// Copyright (c) 2021-2026, R.I. Pienaar and the Choria Project contributors |
2 | 2 | // |
3 | 3 | // SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
@@ -38,7 +38,7 @@ var _ = Describe("AAgent/Watchers/KvWatcher", func() { |
38 | 38 | machine.EXPECT().Debugf(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() |
39 | 39 | machine.EXPECT().Facts().Return(json.RawMessage(`{"fqdn":"ginkgo.example.net"}`)).MinTimes(1) |
40 | 40 | machine.EXPECT().Data().Return(map[string]any{}).MinTimes(1) |
41 | | - machine.EXPECT().DataGet("machines").MinTimes(1) |
| 41 | + machine.EXPECT().DataGet("machines").AnyTimes() |
42 | 42 |
|
43 | 43 | wi, err := New(machine, "kv", nil, nil, "", "", "1m", time.Hour, map[string]any{ |
44 | 44 | "bucket": "PLUGINS", |
@@ -74,6 +74,15 @@ var _ = Describe("AAgent/Watchers/KvWatcher", func() { |
74 | 74 | Expect(err).ToNot(HaveOccurred()) |
75 | 75 | }) |
76 | 76 |
|
| 77 | + It("Should support custom store keys", func() { |
| 78 | + w.properties.StoreKey = "key" |
| 79 | + kve.EXPECT().Value().Return([]byte("\n{\"spec\": \"foo\"}\n")).MinTimes(1) |
| 80 | + machine.EXPECT().DataGet("key").MinTimes(1) |
| 81 | + machine.EXPECT().DataPut("key", map[string]any{"spec": "foo"}).Return(nil).Times(1) |
| 82 | + _, err := w.poll() |
| 83 | + Expect(err).ToNot(HaveOccurred()) |
| 84 | + }) |
| 85 | + |
77 | 86 | It("Should handle a leading and trailing unicode whitespace", func() { |
78 | 87 | kve.EXPECT().Value().Return([]byte("\n \t{\"spec\": \"foo\"}\t \n")).MinTimes(1) |
79 | 88 | machine.EXPECT().DataPut("machines", map[string]any{"spec": "foo"}).Return(nil).Times(1) |
|
0 commit comments