Skip to content

Commit

Permalink
remove validator, enable containedctx linter
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon committed Sep 11, 2024
1 parent afa3748 commit 37380bd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ linters:
- asciicheck
- bidichk
- bodyclose
# - containedctx # TODO enable
- containedctx
- contextcheck
- copyloopvar
- decorder
Expand Down
8 changes: 0 additions & 8 deletions destination/destination_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
)

func TestDestination_OpenSuccess(t *testing.T) {
t.Parallel()

is := is.New(t)

destination := NewDestination()
Expand All @@ -47,8 +45,6 @@ func TestDestination_OpenSuccess(t *testing.T) {
}

func TestDestination_OpenFail(t *testing.T) {
t.Parallel()

is := is.New(t)

destination := NewDestination()
Expand All @@ -67,8 +63,6 @@ func TestDestination_OpenFail(t *testing.T) {
}

func TestDestination_WriteOneMessage(t *testing.T) {
t.Parallel()

is := is.New(t)

subject := "foo_destination_write_one_pubsub"
Expand Down Expand Up @@ -117,8 +111,6 @@ func TestDestination_WriteOneMessage(t *testing.T) {
}

func TestDestination_WriteManyMessages(t *testing.T) {
t.Parallel()

is := is.New(t)

subject := "foo_destination_write_many_pubsub"
Expand Down
38 changes: 11 additions & 27 deletions destination/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,42 @@ package destination
import (
"context"
"testing"

"github.com/conduitio/conduit-commons/config"
)

func TestDestination_Configure(t *testing.T) {
t.Parallel()

type args struct {
ctx context.Context
cfg map[string]string
}

tests := []struct {
name string
args args
cfg config.Config
wantErr bool
}{
{
name: "success, correct config",
args: args{
ctx: context.Background(),
cfg: map[string]string{
ConfigUrls: "nats://127.0.0.1:4222",
ConfigSubject: "foo",
},
cfg: config.Config{
ConfigUrls: "nats://127.0.0.1:4222",
ConfigSubject: "foo",
},
wantErr: false,
},
{
name: "fail, empty config",
args: args{
ctx: context.Background(),
cfg: map[string]string{},
},
name: "fail, empty config",
cfg: config.Config{},
wantErr: true,
},
{
name: "fail, invalid config",
args: args{
ctx: context.Background(),
cfg: map[string]string{
ConfigUrls: "nats://127.0.0.1:4222",
},
cfg: config.Config{
ConfigUrls: "nats://127.0.0.1:4222",
},
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

s := &Destination{}
if err := s.Configure(tt.args.ctx, tt.args.cfg); (err != nil) != tt.wantErr {
if err := s.Configure(context.Background(), tt.cfg); (err != nil) != tt.wantErr {
t.Errorf("Source.Configure() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
23 changes: 4 additions & 19 deletions source/pubsub/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
)

func TestPubSubIterator_HasNext(t *testing.T) {
t.Parallel()

type fields struct {
messages chan *nats.Msg
}
Expand Down Expand Up @@ -63,8 +61,6 @@ func TestPubSubIterator_HasNext(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

i := &Iterator{
messages: tt.fields.messages,
}
Expand All @@ -83,8 +79,6 @@ func TestPubSubIterator_HasNext(t *testing.T) {
}

func TestPubSubIterator_Next(t *testing.T) {
t.Parallel()

type fields struct {
messages chan *nats.Msg
}
Expand Down Expand Up @@ -139,8 +133,6 @@ func TestPubSubIterator_Next(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

i := &Iterator{
messages: tt.fields.messages,
}
Expand Down Expand Up @@ -188,8 +180,6 @@ func TestPubSubIterator_Next(t *testing.T) {
}

func TestPubSubIterator_messageToRecord(t *testing.T) {
t.Parallel()

type args struct {
msg *nats.Msg
}
Expand Down Expand Up @@ -235,8 +225,6 @@ func TestPubSubIterator_messageToRecord(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

i := &Iterator{}

got, err := i.messageToRecord(tt.args.msg)
Expand All @@ -246,11 +234,8 @@ func TestPubSubIterator_messageToRecord(t *testing.T) {
return
}

// copy tt.want in order to avoid race conditions with t.Parallel
copyWant := tt.want

// we don't care about time
copyWant.Metadata = got.Metadata
tt.want.Metadata = got.Metadata

// check if the position is a valid UUID
_, err = uuid.FromBytes(got.Position)
Expand All @@ -260,10 +245,10 @@ func TestPubSubIterator_messageToRecord(t *testing.T) {
return
}

copyWant.Position = got.Position
tt.want.Position = got.Position

if !reflect.DeepEqual(got, copyWant) {
t.Errorf("PubSubIterator.messageToRecord() = %v, want %v", got, copyWant)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("PubSubIterator.messageToRecord() = %v, want %v", got, tt.want)
}
})
}
Expand Down
107 changes: 0 additions & 107 deletions validator/validator.go

This file was deleted.

Loading

0 comments on commit 37380bd

Please sign in to comment.