From 8ca8c5598827d74b3ded73a1d0c8856e48298150 Mon Sep 17 00:00:00 2001 From: Thom Carlin Date: Wed, 16 Oct 2024 12:23:50 -0400 Subject: [PATCH] Add tcp listener test (#1166) --- pkg/backends/tcp_test.go | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pkg/backends/tcp_test.go diff --git a/pkg/backends/tcp_test.go b/pkg/backends/tcp_test.go new file mode 100644 index 000000000..7ff5b93a4 --- /dev/null +++ b/pkg/backends/tcp_test.go @@ -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) + } + }) + } +}