Skip to content

Commit

Permalink
Add null backend test (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored Oct 14, 2024
1 parent fe238e8 commit 3ee08e0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
schedule:
- cron: '41 15 * * 4'
push:
branches: [ "devel" ]
branches: ["devel"]

# Declare default permissions as read only.
permissions: read-all
Expand All @@ -32,12 +32,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # v4.4.2
uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # v4.4.2
with:
name: SARIF file
path: results.sarif
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-reporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ jobs:
&& github.repository == 'ansible/receptor'
&& github.ref_name == github.event.repository.default_branch
run: >-
curl -v --user "${{ vars.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}:${{ secrets.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}"
--form "[email protected]"
--form "component_name=receptor"
--form "git_commit_sha=${{ github.sha }}"
--form "git_repository_url=https://github.com/${{ github.repository }}"
curl -v --user "${{ vars.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}:${{ secrets.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}"
--form "[email protected]"
--form "component_name=receptor"
--form "git_commit_sha=${{ github.sha }}"
--form "git_repository_url=https://github.com/${{ github.repository }}"
"${{ vars.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}/api/results/upload/"
- name: get k8s logs
Expand Down
1 change: 0 additions & 1 deletion docs/source/user_guide/configuration_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1071,4 +1071,3 @@ Sign Request and Produce Certificate
tcp-clients:
- address: localhost:2223
service: foo
58 changes: 58 additions & 0 deletions pkg/backends/null_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package backends_test

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

"github.com/ansible/receptor/pkg/backends"
Expand Down Expand Up @@ -37,6 +39,62 @@ func TestNullBackendCfgGetAddr(t *testing.T) {
}
}

func TestNullBackendCfg_Start(t *testing.T) {
type fields struct {
Local bool
}
type args struct {
in0 context.Context
in1 *sync.WaitGroup
}
tests := []struct {
name string
fields fields
args args
wantKind reflect.Kind
wantType string
wantErr bool
}{
{
name: "Positive",
fields: fields{
Local: true,
},
args: args{
in0: nil,
in1: nil,
},
wantKind: reflect.Chan,
wantType: "netceptor.BackendSession",
wantErr: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := backends.NullBackendCfg{
Local: tt.fields.Local,
}
got, err := cfg.Start(tt.args.in0, tt.args.in1)
defer close(got)

if (err != nil) != tt.wantErr {
t.Errorf("%s: NullBackendCfg.Start() error = %+v, wantErr %+v", tt.name, err, tt.wantErr)

return
}

if reflect.ValueOf(got).Kind() == tt.wantKind {
if reflect.ValueOf(got).Type().Elem().String() != tt.wantType {
t.Errorf("%s: NullBackendCfg.Start() gotType = %+v, wantType = %+v", tt.name, reflect.ValueOf(got).Type().Elem(), tt.wantType)
}
} else {
t.Errorf("%s: NullBackendCfg.Start() gotKind = %+v, wantKind = %+v", tt.name, reflect.ValueOf(got).Kind(), tt.wantKind)
}
})
}
}

func TestNullBackendCfgGetTLS(t *testing.T) {
type fields struct {
Local bool
Expand Down

0 comments on commit 3ee08e0

Please sign in to comment.