Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Oct 14, 2024
1 parent 20bb8cb commit cec581e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"testing"

regErrors "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

Expand Down Expand Up @@ -36,6 +37,32 @@ func (m MemoryMetadata) Etag() string {
return m.etag
}

func TestExistsTooBig(t *testing.T) {
ctx := context.TODO()
opath := &pluginsIOMock.OutputFilePaths{}
opath.OnGetErrorPath().Return("")
deckPath := "some.file"
opath.OnGetOutputPath().Return(storage.DataReference(deckPath))

t.Run("too large", func(t *testing.T) {
store := &storageMocks.ComposedProtobufStore{}
store.OnHead(ctx, "some.file").Return(MemoryMetadata{
exists: true,
size: 2,
}, nil)

r := RemoteFileOutputReader{
outPath: opath,
store: store,
maxPayloadSize: 1,
}

_, err := r.Exists(ctx)
assert.Error(t, err)
assert.True(t, regErrors.Is(err, ErrRemoteFileExceedsMaxSize))
})
}

func TestReadOrigin(t *testing.T) {
ctx := context.TODO()

Expand Down

0 comments on commit cec581e

Please sign in to comment.