Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to the Source. #9

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions destination/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type Writer interface {
type Destination struct {
sdk.UnimplementedDestination

config config.Destination
db *sqlx.DB
writer Writer
cfg config.Destination
}

// NewDestination initialises a new Destination.
Expand Down Expand Up @@ -75,7 +75,7 @@ func (d *Destination) Parameters() map[string]sdk.Parameter {
func (d *Destination) Configure(ctx context.Context, cfg map[string]string) (err error) {
sdk.Logger(ctx).Info().Msg("Configuring ClickHouse Destination...")

d.cfg, err = config.ParseDestination(cfg)
d.config, err = config.ParseDestination(cfg)
if err != nil {
return fmt.Errorf("parse destination config: %w", err)
}
Expand All @@ -87,7 +87,7 @@ func (d *Destination) Configure(ctx context.Context, cfg map[string]string) (err
func (d *Destination) Open(ctx context.Context) (err error) {
sdk.Logger(ctx).Info().Msg("Opening a ClickHouse Destination...")

db, err := sqlx.Open("clickhouse", d.cfg.URL)
db, err := sqlx.Open("clickhouse", d.config.URL)
if err != nil {
return fmt.Errorf("open connection: %w", err)
}
Expand All @@ -97,10 +97,12 @@ func (d *Destination) Open(ctx context.Context) (err error) {
return fmt.Errorf("ping: %w", err)
}

d.db = db

d.writer, err = writer.NewWriter(ctx, writer.Params{
DB: db,
Table: d.cfg.Table,
KeyColumns: d.cfg.KeyColumns,
Table: d.config.Table,
KeyColumns: d.config.KeyColumns,
})
if err != nil {
return fmt.Errorf("new writer: %w", err)
Expand Down
Loading