Merge pull request #3787 from thaJeztah/simplify_mocks
This commit is contained in:
commit
21622ca699
4 changed files with 4 additions and 54 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
type mockBlobService struct {
|
type mockBlobService struct {
|
||||||
descriptors map[digest.Digest]distribution.Descriptor
|
descriptors map[digest.Digest]distribution.Descriptor
|
||||||
|
distribution.BlobService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
||||||
|
@ -21,14 +22,6 @@ func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distri
|
||||||
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
||||||
d := distribution.Descriptor{
|
d := distribution.Descriptor{
|
||||||
Digest: digest.FromBytes(p),
|
Digest: digest.FromBytes(p),
|
||||||
|
@ -39,14 +32,6 @@ func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte)
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBuilder(t *testing.T) {
|
func TestBuilder(t *testing.T) {
|
||||||
imgJSON := []byte(`{
|
imgJSON := []byte(`{
|
||||||
"created": "2015-10-31T22:22:56.015925234Z",
|
"created": "2015-10-31T22:22:56.015925234Z",
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
|
|
||||||
type mockBlobService struct {
|
type mockBlobService struct {
|
||||||
descriptors map[digest.Digest]distribution.Descriptor
|
descriptors map[digest.Digest]distribution.Descriptor
|
||||||
|
distribution.BlobService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
||||||
|
@ -26,14 +27,6 @@ func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distri
|
||||||
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
||||||
d := distribution.Descriptor{
|
d := distribution.Descriptor{
|
||||||
Digest: digest.FromBytes(p),
|
Digest: digest.FromBytes(p),
|
||||||
|
@ -44,14 +37,6 @@ func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte)
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEmptyTar(t *testing.T) {
|
func TestEmptyTar(t *testing.T) {
|
||||||
// Confirm that gzippedEmptyTar expands to 1024 NULL bytes.
|
// Confirm that gzippedEmptyTar expands to 1024 NULL bytes.
|
||||||
var decompressed [2048]byte
|
var decompressed [2048]byte
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
type mockBlobService struct {
|
type mockBlobService struct {
|
||||||
descriptors map[digest.Digest]distribution.Descriptor
|
descriptors map[digest.Digest]distribution.Descriptor
|
||||||
|
distribution.BlobService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {
|
||||||
|
@ -20,14 +21,6 @@ func (bs *mockBlobService) Stat(ctx context.Context, dgst digest.Digest) (distri
|
||||||
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
return distribution.Descriptor{}, distribution.ErrBlobUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte) (distribution.Descriptor, error) {
|
||||||
d := distribution.Descriptor{
|
d := distribution.Descriptor{
|
||||||
Digest: digest.FromBytes(p),
|
Digest: digest.FromBytes(p),
|
||||||
|
@ -38,14 +31,6 @@ func (bs *mockBlobService) Put(ctx context.Context, mediaType string, p []byte)
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bs *mockBlobService) Create(ctx context.Context, options ...distribution.BlobCreateOption) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *mockBlobService) Resume(ctx context.Context, id string) (distribution.BlobWriter, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBuilder(t *testing.T) {
|
func TestBuilder(t *testing.T) {
|
||||||
imgJSON := []byte(`{
|
imgJSON := []byte(`{
|
||||||
"architecture": "amd64",
|
"architecture": "amd64",
|
||||||
|
|
|
@ -13,10 +13,9 @@ import (
|
||||||
type mockTagStore struct {
|
type mockTagStore struct {
|
||||||
mapping map[string]distribution.Descriptor
|
mapping map[string]distribution.Descriptor
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
distribution.TagService
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ distribution.TagService = &mockTagStore{}
|
|
||||||
|
|
||||||
func (m *mockTagStore) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
|
func (m *mockTagStore) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
|
@ -58,10 +57,6 @@ func (m *mockTagStore) All(ctx context.Context) ([]string, error) {
|
||||||
return tags, nil
|
return tags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockTagStore) Lookup(ctx context.Context, digest distribution.Descriptor) ([]string, error) {
|
|
||||||
panic("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testProxyTagService(local, remote map[string]distribution.Descriptor) *proxyTagService {
|
func testProxyTagService(local, remote map[string]distribution.Descriptor) *proxyTagService {
|
||||||
if local == nil {
|
if local == nil {
|
||||||
local = make(map[string]distribution.Descriptor)
|
local = make(map[string]distribution.Descriptor)
|
||||||
|
|
Loading…
Reference in a new issue