implement some ad-hoc mocks for responses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -3,6 +3,7 @@ package image
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -28,6 +29,14 @@ type fakeClient struct {
|
||||
imageBuildFunc func(context.Context, io.Reader, client.ImageBuildOptions) (client.ImageBuildResult, error)
|
||||
}
|
||||
|
||||
type fakeStreamResult struct {
|
||||
io.ReadCloser
|
||||
client.ImagePushResponse // same interface as [client.ImagePullResponse]
|
||||
}
|
||||
|
||||
func (e fakeStreamResult) Read(p []byte) (int, error) { return e.ReadCloser.Read(p) }
|
||||
func (e fakeStreamResult) Close() error { return e.ReadCloser.Close() }
|
||||
|
||||
func (cli *fakeClient) ImageTag(_ context.Context, options client.ImageTagOptions) (client.ImageTagResult, error) {
|
||||
if cli.imageTagFunc != nil {
|
||||
return cli.imageTagFunc(options)
|
||||
@ -54,7 +63,7 @@ func (cli *fakeClient) ImagePush(_ context.Context, ref string, options client.I
|
||||
return cli.imagePushFunc(ref, options)
|
||||
}
|
||||
// FIXME(thaJeztah): how to mock this?
|
||||
return nil, nil
|
||||
return fakeStreamResult{ReadCloser: http.NoBody}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) Info(_ context.Context) (system.Info, error) {
|
||||
@ -69,7 +78,7 @@ func (cli *fakeClient) ImagePull(_ context.Context, ref string, options client.I
|
||||
return cli.imagePullFunc(ref, options)
|
||||
}
|
||||
// FIXME(thaJeztah): how to mock this?
|
||||
return nil, nil
|
||||
return fakeStreamResult{ReadCloser: http.NoBody}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ImagesPrune(_ context.Context, opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
|
||||
|
||||
Reference in New Issue
Block a user