File tree Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ go 1.22.0
4
4
5
5
require (
6
6
github.com/shimmeringbee/zcl v0.0.0-20240509210644-817a66d91348
7
+ github.com/shimmeringbee/zigbee v0.0.0-20201027194100-4e53cafc0f7a
7
8
github.com/stretchr/testify v1.9.0
8
9
)
9
10
10
11
require (
11
12
github.com/davecgh/go-spew v1.1.1 // indirect
12
13
github.com/pmezard/go-difflib v1.0.0 // indirect
13
14
github.com/shimmeringbee/bytecodec v0.0.0-20201107142444-94bb5c0baaee // indirect
14
- github.com/shimmeringbee/zigbee v0.0.0-20201027194100-4e53cafc0f7a // indirect
15
15
github.com/stretchr/objx v0.5.2 // indirect
16
16
gopkg.in/yaml.v3 v3.0.1 // indirect
17
17
)
Original file line number Diff line number Diff line change @@ -16,6 +16,15 @@ type memory struct {
16
16
sections map [string ]persistence.Section
17
17
}
18
18
19
+ func (m * memory ) SectionExists (key string ) bool {
20
+ m .m .RLock ()
21
+ defer m .m .RUnlock ()
22
+
23
+ _ , found := m .sections [key ]
24
+
25
+ return found
26
+ }
27
+
19
28
func (m * memory ) Section (key ... string ) persistence.Section {
20
29
m .m .RLock ()
21
30
s , ok := m .sections [key [0 ]]
@@ -48,7 +57,7 @@ func (m *memory) SectionKeys() []string {
48
57
return keys
49
58
}
50
59
51
- func (m * memory ) DeleteSection (key string ) bool {
60
+ func (m * memory ) SectionDelete (key string ) bool {
52
61
m .m .Lock ()
53
62
defer m .m .Unlock ()
54
63
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ func TestMemory_DeleteSection(t *testing.T) {
252
252
s .Section ("one" )
253
253
assert .Contains (t , s .SectionKeys (), "one" )
254
254
255
- s .DeleteSection ("one" )
255
+ s .SectionDelete ("one" )
256
256
assert .NotContains (t , s .SectionKeys (), "one" )
257
257
})
258
258
}
@@ -267,6 +267,16 @@ func TestMemory_Exists(t *testing.T) {
267
267
})
268
268
}
269
269
270
+ func TestMemory_SectionExists (t * testing.T ) {
271
+ t .Run ("returns if a section exists" , func (t * testing.T ) {
272
+ s := New ()
273
+
274
+ _ = s .Section ("key" )
275
+ assert .True (t , s .SectionExists ("key" ))
276
+ assert .False (t , s .SectionExists ("otherKey" ))
277
+ })
278
+ }
279
+
270
280
func TestMemory_SectionKeyNotClash (t * testing.T ) {
271
281
t .Run ("ensure that keys and sections dont shared the same name space" , func (t * testing.T ) {
272
282
s := New ()
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ package persistence
3
3
type Section interface {
4
4
Section (key ... string ) Section
5
5
SectionKeys () []string
6
- DeleteSection (key string ) bool
6
+ SectionExists (key string ) bool
7
+ SectionDelete (key string ) bool
7
8
8
9
Keys () []string
9
10
Exists (key string ) bool
You can’t perform that action at this time.
0 commit comments