-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinterfaces.go
More file actions
31 lines (26 loc) · 1.07 KB
/
interfaces.go
File metadata and controls
31 lines (26 loc) · 1.07 KB
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
package storage
import (
"github.com/docker/distribution/context"
storagedriver "github.com/docker/distribution/registry/storage/driver"
)
// ObjectStatter is a *(github.com/minio/minio-go).Client compatible interface, restricted to
// just the StatObject function. You can use it in your code for easier unit testing without
// any external dependencies (like access to S3).
type ObjectStatter interface {
Stat(ctx context.Context, path string) (storagedriver.FileInfo, error)
}
// FakeStatObjectCall represents a single call to StatObject on the FakeObjectStatter.
type FakeStatObjectCall struct {
Path string
}
// FakeObjectStatter is a mock function that can be swapped in for an ObjectStatter, so you can
// unit test your code.
type FakeObjectStatter struct {
Fn func(context.Context, string) (storagedriver.FileInfo, error)
Calls []FakeStatObjectCall
}
// Stat is the interface definition.
func (f *FakeObjectStatter) Stat(ctx context.Context, path string) (storagedriver.FileInfo, error) {
f.Calls = append(f.Calls, FakeStatObjectCall{Path: path})
return f.Fn(ctx, path)
}