Skip to content

Commit

Permalink
test: storage catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekatr committed May 8, 2023
1 parent e32a9df commit 1fe8da8
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/storage/minio/cataloger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package minio

import (
"context"
"testing"

"github.com/gomods/athens/pkg/paths"
"github.com/gomods/athens/pkg/storage/minio/mocks"
"github.com/minio/minio-go/v6"
"github.com/stretchr/testify/require"
)

func TestCatalog(t *testing.T) {
token := "test-token"
bucketName := "test-bucket"
pageSize := 10

mockMinioCore := mocks.NewMinioCore(t)
mockMinioCore.On("ListObjectsV2", bucketName, "", token, false, "", 0, "").Return(minio.ListBucketV2Result{
Contents: []minio.ObjectInfo{
{
Key: "test-version/test.info",
},
},
}, nil)

st := &storageImpl{
minioCore: mockMinioCore,
bucketName: bucketName,
}

gotAllPathsParams, gotToken, gotErr := st.Catalog(context.Background(), token, pageSize)

expectedToken := ""
expectedAllPathsParams := []paths.AllPathParams{{Module: "/test.info", Version: "test-version"}}

require.NoError(t, gotErr)
require.Equal(t, expectedToken, gotToken)
require.Equal(t, expectedAllPathsParams, gotAllPathsParams)
}
52 changes: 52 additions & 0 deletions pkg/storage/minio/mocks/minioCore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1fe8da8

Please sign in to comment.