Skip to content

Commit

Permalink
Add tcp listener test (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored Oct 16, 2024
1 parent b6105fc commit 8ca8c55
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions pkg/backends/tcp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package backends

import (
"crypto/tls"
"reflect"
"testing"

"github.com/ansible/receptor/pkg/logger"
)

func TestNewTCPListener(t *testing.T) {
type args struct {
address string
tls *tls.Config
logger *logger.ReceptorLogger
}
tests := []struct {
name string
args args
want *TCPListener
wantErr bool
}{
{
name: "Positive",
args: args{
address: "127.0.0.1:9999",
tls: nil,
logger: nil,
},
want: &TCPListener{
address: "127.0.0.1:9999",
TLS: nil,
li: nil,
innerLi: nil,
logger: nil,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewTCPListener(tt.args.address, tt.args.tls, tt.args.logger)
if (err != nil) != tt.wantErr {
t.Errorf("NewTCPListener() error = %v, wantErr %v", err, tt.wantErr)

return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewTCPListener() = %+v, want %+v", got, tt.want)
}
})
}
}

0 comments on commit 8ca8c55

Please sign in to comment.