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 tcp listener test #1166

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Changes from all 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
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)
}
})
}
}