Skip to content

Commit

Permalink
feat(grpc): add asset, search, lineage (#103)
Browse files Browse the repository at this point in the history
* feat(grpc): add asset, search, lineage

* fix(test): increase coverage
  • Loading branch information
mabdh authored Mar 31, 2022
1 parent 2089833 commit 970c43c
Show file tree
Hide file tree
Showing 50 changed files with 14,064 additions and 2,043 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME="github.com/odpf/columbus"
VERSION=$(shell git describe --always --tags 2>/dev/null)
COVERFILE="/tmp/columbus.coverprofile"
PROTON_COMMIT := "cdb580faf1f9cc5f0043ef1f8980dd8ac4e04679"
PROTON_COMMIT := "c3146a25d9f321bc721d94dbdf3aec8483a3cb03"

.PHONY: all build test clean install proto

Expand All @@ -24,7 +24,7 @@ dist:

lint:
golangci-lint run

proto: ## Generate the protobuf files
@echo " > generating protobuf from odpf/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make install'"
Expand Down
10 changes: 10 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ func NewGRPCHandler(l log.Logger, deps *Dependencies) *v1beta1.Handler {
return &v1beta1.Handler{
Logger: l,
DiscussionRepository: deps.DiscussionRepository,
AssetRepository: deps.AssetRepository,
LineageRepository: deps.LineageRepository,
StarRepository: deps.StarRepository,
UserService: deps.UserService,
TagService: deps.TagService,
TagTemplateService: deps.TagTemplateService,
DiscoveryRepository: deps.DiscoveryRepository,

//deprecated
DiscoveryService: deps.DiscoveryService,
}
}

Expand Down
12 changes: 6 additions & 6 deletions api/httpapi/handlers/asset_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,14 @@ func TestAssetHandlerGetVersionHistory(t *testing.T) {
Description: `should return http 400 if asset id is not uuid`,
ExpectStatus: http.StatusBadRequest,
Setup: func(ctx context.Context, ar *mocks.AssetRepository) {
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.AssetVersion{}, asset.InvalidError{AssetID: assetID})
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.Asset{}, asset.InvalidError{AssetID: assetID})
},
},
{
Description: `should return http 500 if fetching fails`,
ExpectStatus: http.StatusInternalServerError,
Setup: func(ctx context.Context, ar *mocks.AssetRepository) {
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.AssetVersion{}, errors.New("unknown error"))
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.Asset{}, errors.New("unknown error"))
},
},
{
Expand All @@ -923,24 +923,24 @@ func TestAssetHandlerGetVersionHistory(t *testing.T) {
ar.On("GetVersionHistory", ctx, asset.Config{
Size: 30,
Offset: 50,
}, assetID).Return([]asset.AssetVersion{}, nil, nil)
}, assetID).Return([]asset.Asset{}, nil, nil)
},
},
{
Description: "should return http 200 status along with list of asset versions",
ExpectStatus: http.StatusOK,
Setup: func(ctx context.Context, ar *mocks.AssetRepository) {
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.AssetVersion{
ar.On("GetVersionHistory", ctx, asset.Config{}, assetID).Return([]asset.Asset{
{ID: "testid-1"},
{ID: "testid-2"},
}, nil, nil)
},
PostCheck: func(r *http.Response) error {
expected := []asset.AssetVersion{
expected := []asset.Asset{
{ID: "testid-1"},
{ID: "testid-2"},
}
var actual []asset.AssetVersion
var actual []asset.Asset
err := json.NewDecoder(r.Body).Decode(&actual)
if err != nil {
return fmt.Errorf("error reading response body: %w", err)
Expand Down
Loading

0 comments on commit 970c43c

Please sign in to comment.