Skip to content

Commit

Permalink
chore: add tests to ExecuteWithClient for pipelines cmds (#2111)
Browse files Browse the repository at this point in the history
* refactor: no need to set a default table style

This line is redundant.

* add tests for list pipeline

* fix imports

* rename test file

* empty response test

* test pipelines describe

* move services to single file

* rather do this instead

* create testutils and reorganize internal

* update pipelines ls test

* update

* add test for connectors ls

* refactor connector list test

* test connectors describe

* test processor describe

* test processorplugins describe

* test connectorplugins describe

* compare with entire table

* refactor tests to compare with entire table

* test processors ls

* test procesor plugins ls

* test connectorplugins ls

* remove unneeded call

no need https://github.com/uber-go/mock/blob/v0.5.0/gomock/controller.go#L80-L104

* better test

* separate concerns
  • Loading branch information
raulb authored Jan 30, 2025
1 parent 8b29ae1 commit 9ae2dc5
Show file tree
Hide file tree
Showing 32 changed files with 1,802 additions and 169 deletions.
8 changes: 4 additions & 4 deletions cmd/conduit/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
)

type Client struct {
conn *grpc.ClientConn
apiv1.PipelineServiceClient
apiv1.ProcessorServiceClient
apiv1.ConnectorServiceClient
conn *grpc.ClientConn
PipelineServiceClient PipelineService
ConnectorServiceClient ConnectorService
ProcessorServiceClient ProcessorService
healthgrpc.HealthClient
}

Expand Down
103 changes: 103 additions & 0 deletions cmd/conduit/api/mock/connector_service.go

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

103 changes: 103 additions & 0 deletions cmd/conduit/api/mock/pipeline_service.go

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

103 changes: 103 additions & 0 deletions cmd/conduit/api/mock/processor_service.go

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

49 changes: 49 additions & 0 deletions cmd/conduit/api/services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright © 2025 Meroxa, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

import (
"context"

apiv1 "github.com/conduitio/conduit/proto/api/v1"
"google.golang.org/grpc"
)

//go:generate mockgen -destination=mock/connector_service.go -package=mock . ConnectorService

// ConnectorService defines the methods of the ConnectorServiceClient that are currently used by the CLI.
type ConnectorService interface {
ListConnectors(ctx context.Context, in *apiv1.ListConnectorsRequest, opts ...grpc.CallOption) (*apiv1.ListConnectorsResponse, error)
GetConnector(ctx context.Context, in *apiv1.GetConnectorRequest, opts ...grpc.CallOption) (*apiv1.GetConnectorResponse, error)
ListConnectorPlugins(ctx context.Context, in *apiv1.ListConnectorPluginsRequest, opts ...grpc.CallOption) (*apiv1.ListConnectorPluginsResponse, error)
}

//go:generate mockgen -destination=mock/pipeline_service.go -package=mock . PipelineService

// PipelineService defines the methods of the PipelineServiceClient that are currently used by the CLI.
type PipelineService interface {
ListPipelines(ctx context.Context, in *apiv1.ListPipelinesRequest, opts ...grpc.CallOption) (*apiv1.ListPipelinesResponse, error)
GetPipeline(ctx context.Context, in *apiv1.GetPipelineRequest, opts ...grpc.CallOption) (*apiv1.GetPipelineResponse, error)
GetDLQ(ctx context.Context, in *apiv1.GetDLQRequest, opts ...grpc.CallOption) (*apiv1.GetDLQResponse, error)
}

//go:generate mockgen -destination=mock/processor_service.go -package=mock . ProcessorService

// ProcessorService defines the methods of the ProcessorServiceClient that are currently used by the CLI.
type ProcessorService interface {
ListProcessors(ctx context.Context, in *apiv1.ListProcessorsRequest, opts ...grpc.CallOption) (*apiv1.ListProcessorsResponse, error)
GetProcessor(ctx context.Context, in *apiv1.GetProcessorRequest, opts ...grpc.CallOption) (*apiv1.GetProcessorResponse, error)
ListProcessorPlugins(ctx context.Context, in *apiv1.ListProcessorPluginsRequest, opts ...grpc.CallOption) (*apiv1.ListProcessorPluginsResponse, error)
}
Loading

0 comments on commit 9ae2dc5

Please sign in to comment.