File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ const (
2424
2525// LocalStore is local storage for downloaded top-level metadata.
2626type LocalStore interface {
27+ io.Closer
28+
2729 // GetMeta returns top-level metadata from local storage. The keys are
2830 // in the form `ROLE.json`, with ROLE being a valid top-level role.
2931 GetMeta () (map [string ]json.RawMessage , error )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ func (LocalStoreSuite) TestFileLocalStore(c *C) {
2020 path := filepath .Join (tmp , "tuf.db" )
2121 store , err := FileLocalStore (path )
2222 c .Assert (err , IsNil )
23+ defer store .Close ()
2324
2425 type meta map [string ]json.RawMessage
2526
@@ -43,9 +44,12 @@ func (LocalStoreSuite) TestFileLocalStore(c *C) {
4344 assertGet (meta {"root.json" : rootJSON , "targets.json" : targetsJSON })
4445
4546 // a new store should get the same meta
46- c .Assert (store .( * fileLocalStore ). Close (), IsNil )
47+ c .Assert (store .Close (), IsNil )
4748 store , err = FileLocalStore (path )
4849 c .Assert (err , IsNil )
50+ defer func () {
51+ c .Assert (store .Close (), IsNil )
52+ }()
4953 assertGet (meta {"root.json" : rootJSON , "targets.json" : targetsJSON })
5054}
5155
Original file line number Diff line number Diff line change @@ -23,3 +23,7 @@ func (m memoryLocalStore) DeleteMeta(name string) error {
2323 delete (m , name )
2424 return nil
2525}
26+
27+ func (m memoryLocalStore ) Close () error {
28+ return nil
29+ }
Original file line number Diff line number Diff line change 88
99func TestDeleteMeta (t * testing.T ) {
1010 l := MemoryLocalStore ()
11+ defer func () {
12+ assert .Equal (t , nil , l .Close ())
13+ }()
1114 assert .Equal (t , l .SetMeta ("root.json" , []byte (`
1215 {
1316 "signed": {},
You can’t perform that action at this time.
0 commit comments