File: mocks.go

package info (click to toggle)
aptly 1.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,928 kB
  • sloc: python: 10,398; sh: 252; makefile: 184
file content (36 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package files

import (
	"github.com/aptly-dev/aptly/aptly"
	"github.com/aptly-dev/aptly/utils"
)

type MockChecksumStorage struct {
	Store map[string]utils.ChecksumInfo
}

// NewMockChecksumStorage creates aptly.ChecksumStorage for tests
func NewMockChecksumStorage() aptly.ChecksumStorage {
	return &MockChecksumStorage{
		Store: make(map[string]utils.ChecksumInfo),
	}
}

func (st *MockChecksumStorage) Get(path string) (*utils.ChecksumInfo, error) {
	c, ok := st.Store[path]
	if !ok {
		return nil, nil
	}

	return &c, nil
}

func (st *MockChecksumStorage) Update(path string, c *utils.ChecksumInfo) error {
	st.Store[path] = *c
	return nil
}

// Check interface
var (
	_ aptly.ChecksumStorage = &MockChecksumStorage{}
)