From af4470278043659b4565e2ac1c5b62a16e5dcb38 Mon Sep 17 00:00:00 2001 From: Thom Carlin Date: Tue, 15 Oct 2024 08:45:48 -0400 Subject: [PATCH 1/2] Add dialersession test --- pkg/backends/utils_test.go | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pkg/backends/utils_test.go diff --git a/pkg/backends/utils_test.go b/pkg/backends/utils_test.go new file mode 100644 index 000000000..e6a23610d --- /dev/null +++ b/pkg/backends/utils_test.go @@ -0,0 +1,55 @@ +package backends + +import ( + "context" + "reflect" + "sync" + "testing" + "time" + + "github.com/ansible/receptor/pkg/logger" + "github.com/ansible/receptor/pkg/netceptor" +) + +func TestdialerSession(t *testing.T) { + type args struct { + ctx context.Context + wg *sync.WaitGroup + redial bool + redialDelay time.Duration + logger *logger.ReceptorLogger + df dialerFunc + } + tests := []struct { + name string + args args + want chan netceptor.BackendSession + wantErr bool + }{ + { + name: "Positive", + args: args{ + ctx: nil, + wg: nil, + redial: true, + redialDelay: 1 * time.Second, + logger: nil, + df: nil, + }, + want: nil, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := dialerSession(tt.args.ctx, tt.args.wg, tt.args.redial, tt.args.redialDelay, tt.args.logger, tt.args.df) + if (err != nil) != tt.wantErr { + t.Errorf("dialerSession() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("dialerSession() = %v, want %v", got, tt.want) + } + }) + } +} From a0bb7676a1f212b18a03beb8c1f504822458ff1c Mon Sep 17 00:00:00 2001 From: Thom Carlin Date: Tue, 15 Oct 2024 08:48:40 -0400 Subject: [PATCH 2/2] gci-d file --- pkg/backends/utils_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/backends/utils_test.go b/pkg/backends/utils_test.go index e6a23610d..8fc5c9b48 100644 --- a/pkg/backends/utils_test.go +++ b/pkg/backends/utils_test.go @@ -27,17 +27,17 @@ func TestdialerSession(t *testing.T) { wantErr bool }{ { - name: "Positive", - args: args{ - ctx: nil, - wg: nil, - redial: true, - redialDelay: 1 * time.Second, - logger: nil, - df: nil, + name: "Positive", + args: args{ + ctx: nil, + wg: nil, + redial: true, + redialDelay: 1 * time.Second, + logger: nil, + df: nil, }, - want: nil, - wantErr: false, + want: nil, + wantErr: false, }, } for _, tt := range tests {