Skip to content

Commit

Permalink
upgrade golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
maha-hajja committed Apr 20, 2023
1 parent fa3c28d commit 352699e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.50.1
version: v1.52.2
9 changes: 7 additions & 2 deletions columntypes/columntypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type Querier interface {
}

// TransformRow converts row map values to appropriate Go types, based on the columnTypes.
func TransformRow(ctx context.Context, row map[string]any, columnTypes map[string]string) (map[string]any, error) {
func TransformRow(_ context.Context, row map[string]any, columnTypes map[string]string) (map[string]any, error) {
result := make(map[string]any, len(row))

for key, value := range row {
Expand Down Expand Up @@ -100,7 +100,7 @@ func TransformRow(ctx context.Context, row map[string]any, columnTypes map[strin

// ConvertStructureData converts a sdk.StructureData values to a proper database types.
func ConvertStructureData(
ctx context.Context,
_ context.Context,
columnTypes map[string]string,
data sdk.StructuredData,
) (sdk.StructuredData, error) {
Expand Down Expand Up @@ -177,6 +177,7 @@ func GetColumnTypes(ctx context.Context, querier Querier, tableName string) (map
if err != nil {
return nil, fmt.Errorf("query column types: %w", err)
}
defer rows.Close()

columnTypes := make(map[string]string)
for rows.Next() {
Expand All @@ -188,6 +189,10 @@ func GetColumnTypes(ctx context.Context, querier Querier, tableName string) (map
columnTypes[columnName] = dataType
}

if err := rows.Err(); err != nil {
return nil, fmt.Errorf("iterate rows error: %w", err)
}

return columnTypes, nil
}

Expand Down
9 changes: 5 additions & 4 deletions columntypes/columntypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ func Test_parseToTime(t *testing.T) {
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tc := tt // create a new variable inside the loop and assign the loop variable to it
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

_, err := parseToTime(tt.strValue)
if (err != nil) != tt.wantErr {
t.Errorf("Parse() error = %v, wantErr %v", err, tt.wantErr)
_, err := parseToTime(tc.strValue)
if (err != nil) != tc.wantErr {
t.Errorf("Parse() error = %v, wantErr %v", err, tc.wantErr)

return
}
Expand Down
2 changes: 1 addition & 1 deletion destination/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (d *Destination) Parameters() map[string]sdk.Parameter {
}

// Configure parses and initializes the config.
func (d *Destination) Configure(ctx context.Context, cfg map[string]string) error {
func (d *Destination) Configure(_ context.Context, cfg map[string]string) error {
configuration, err := config.Parse(cfg)
if err != nil {
return fmt.Errorf("parse config: %w", err)
Expand Down
16 changes: 16 additions & 0 deletions destination/destination_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func TestIntegrationDestination_Write_Insert_Success(t *testing.T) {
}
}

if err := rows.Err(); err != nil {
t.Error("iterate rows error: %w", err)
}

if id != preparedID {
t.Error(errors.New("id and prepared id not equal"))
}
Expand Down Expand Up @@ -252,6 +256,10 @@ func TestIntegrationDestination_Write_Update_Success(t *testing.T) {
}
}

if err := rows.Err(); err != nil {
t.Error("iterate rows error: %w", err)
}

if clVarchar != preparedVarchar {
t.Error(errors.New("clVarchar and preparedVarchar not equal"))
}
Expand Down Expand Up @@ -364,6 +372,10 @@ func TestIntegrationDestination_Write_Update_Composite_Keys_Success(t *testing.T
}
}

if err := rows.Err(); err != nil {
t.Error("iterate rows error: %w", err)
}

if clVarchar != preparedVarchar {
t.Error(errors.New("clVarchar and preparedVarchar not equal"))
}
Expand Down Expand Up @@ -479,6 +491,10 @@ func TestIntegrationDestination_Write_Delete_Success(t *testing.T) {
}
}

if err := rows.Err(); err != nil {
t.Error("iterate rows error: %w", err)
}

if count != 0 {
t.Error(errors.New("count not zero"))
}
Expand Down
2 changes: 1 addition & 1 deletion destination/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewWriter(ctx context.Context, params Params) (*Writer, error) {
}

// Close closes the underlying db connection.
func (w *Writer) Close(ctx context.Context) error {
func (w *Writer) Close(_ context.Context) error {
return w.db.Close()
}

Expand Down

0 comments on commit 352699e

Please sign in to comment.