Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
storage: fix noop writer to help dumpling to do some tests (#1248) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jun 22, 2021
1 parent aee5fb6 commit 2fc761c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/storage/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *noopStorage) URI() string {

// Create implements ExternalStorage interface.
func (*noopStorage) Create(ctx context.Context, name string) (ExternalFileWriter, error) {
panic("noop storage not support multi-upload")
return &noopWriter{}, nil
}

func newNoopStorage() *noopStorage {
Expand All @@ -49,13 +49,23 @@ func newNoopStorage() *noopStorage {
type noopReader struct{}

func (noopReader) Read(p []byte) (n int, err error) {
return 0, nil
return len(p), nil
}

func (noopReader) Close() error {
return nil
}

func (noopReader) Seek(offset int64, whence int) (int64, error) {
return 0, nil
return offset, nil
}

type noopWriter struct{}

func (noopWriter) Write(ctx context.Context, p []byte) (int, error) {
return len(p), nil
}

func (noopWriter) Close(ctx context.Context) error {
return nil
}

0 comments on commit 2fc761c

Please sign in to comment.