-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6105fc
commit 8ca8c55
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |