Skip to content

Commit

Permalink
Add tcp dialer test
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat committed Oct 17, 2024
1 parent 6ca199f commit bcc54dd
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pkg/backends/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,57 @@ func TestTCPListenerStart(t *testing.T) {
})
}
}

func TestTCPDialerStart(t *testing.T) {
type fields struct {
address string
redial bool
tls *tls.Config
logger *logger.ReceptorLogger
}
type args struct {
ctx context.Context
wg *sync.WaitGroup
}
tests := []struct {
name string
fields fields
args args
want chan netceptor.BackendSession
wantErr bool
}{
{
name: "Positive",
fields: fields{
address: "127.0.0.1:9998",
redial: true,
tls: nil,
logger: logger.NewReceptorLogger("TCPtest"),
},
args: args{
ctx: context.Background(),
wg: &sync.WaitGroup{},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &TCPDialer{
address: tt.fields.address,
redial: tt.fields.redial,
tls: tt.fields.tls,
logger: tt.fields.logger,
}
got, err := b.Start(tt.args.ctx, tt.args.wg)
if (err != nil) != tt.wantErr {
t.Errorf("TCPDialer.Start() error = %+v, wantErr %+v", err, tt.wantErr)

return
}
if got == nil {
t.Errorf("TCPDialer.Start() got = nil")
}
})
}
}

0 comments on commit bcc54dd

Please sign in to comment.