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

Switch to 1-to-1 TestID to Result struct #1666

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
OCT_IMAGE_NAME: testnetworkfunction/oct
OCT_IMAGE_TAG: latest
GRADETOOL_IMAGE_NAME: testnetworkfunction/gradetool
GRADETOOL_IMAGE_TAG: latest
GRADETOOL_IMAGE_TAG: test1
sebrandon1 marked this conversation as resolved.
Show resolved Hide resolved
TNF_CONTAINER_CLIENT: docker
TNF_NON_INTRUSIVE_ONLY: false
TNF_ALLOW_PREFLIGHT_INSECURE: false
Expand Down
8 changes: 3 additions & 5 deletions cmd/tnf/claim/compare/testcases/testcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ type DiffReport struct {
func getTestCasesResultsMap(testSuiteResults claim.TestSuiteResults) map[string]string {
testCaseResults := map[string]string{}

for _, results := range testSuiteResults {
for i := range results {
testCase := results[i]
testCaseResults[testCase.TestID.ID] = testCase.State
}
//nolint:gocritic
for _, testCase := range testSuiteResults {
testCaseResults[testCase.TestID.ID] = testCase.State
}

return testCaseResults
Expand Down
96 changes: 45 additions & 51 deletions cmd/tnf/claim/compare/testcases/testcases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ func TestGetTestCasesResultsMap(t *testing.T) {
{
description: "one test case in the access-control ts",
results: claim.TestSuiteResults{
"access-control": []claim.TestCaseResult{
{
TestID: claim.TestCaseID{
ID: "access-control-ssh-daemons",
},
State: "skipped",
"access-control": claim.TestCaseResult{
TestID: claim.TestCaseID{
ID: "access-control-ssh-daemons",
},
State: "skipped",
},
},
expectedTestCasesResultsMap: map[string]string{
Expand All @@ -43,33 +41,29 @@ func TestGetTestCasesResultsMap(t *testing.T) {
{
description: "two test suites with two test cases each",
results: claim.TestSuiteResults{
"access-control": []claim.TestCaseResult{
{
TestID: claim.TestCaseID{
ID: "access-control-ssh-daemons",
},
State: "skipped",
"access-control-ssh-daemons": claim.TestCaseResult{
TestID: claim.TestCaseID{
ID: "access-control-ssh-daemons",
},
{
TestID: claim.TestCaseID{
ID: "access-control-sys-admin-capability-check",
},
State: "passed",
State: "skipped",
},
"access-control-sys-admin-capability-check": claim.TestCaseResult{
TestID: claim.TestCaseID{
ID: "access-control-sys-admin-capability-check",
},
State: "passed",
},
"lifecycle": []claim.TestCaseResult{
{
TestID: claim.TestCaseID{
ID: "lifecycle-pod-scheduling",
},
State: "skipped",
"lifecycle-pod-scheduling": claim.TestCaseResult{
TestID: claim.TestCaseID{
ID: "lifecycle-pod-scheduling",
},
{
TestID: claim.TestCaseID{
ID: "lifecycle-pod-high-availability",
},
State: "failed",
State: "skipped",
},
"lifecycle-pod-high-availability": claim.TestCaseResult{
TestID: claim.TestCaseID{
ID: "lifecycle-pod-high-availability",
},
State: "failed",
},
},
expectedTestCasesResultsMap: map[string]string{
Expand Down Expand Up @@ -210,9 +204,9 @@ func TestGetDiffReport(t *testing.T) {
}{
{
description: "results1 empty, results2 with one tc result",
results1: map[string][]claim.TestCaseResult{},
results2: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
results1: map[string]claim.TestCaseResult{},
results2: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
},
expectedDiffReport: DiffReport{
Claim1ResultsSummary: TcResultsSummary{},
Expand All @@ -229,11 +223,11 @@ func TestGetDiffReport(t *testing.T) {
},
{
description: "results1 and results2 have the same passing tc",
results1: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
results1: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
},
results2: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
results2: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
},
expectedDiffReport: DiffReport{
Claim1ResultsSummary: TcResultsSummary{Passed: 1},
Expand All @@ -244,11 +238,11 @@ func TestGetDiffReport(t *testing.T) {
},
{
description: "results1 and results2 have same tc with different result",
results1: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
results1: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
},
results2: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "failed"}},
results2: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "failed"},
},
expectedDiffReport: DiffReport{
Claim1ResultsSummary: TcResultsSummary{Passed: 1},
Expand All @@ -259,13 +253,13 @@ func TestGetDiffReport(t *testing.T) {
},
{
description: "results1 and results2 have the same two tcs from different test suites, both with different results",
results1: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
"lifecycle": {{TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "failed"}},
results1: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
"lifecycle": {TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "failed"},
},
results2: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "failed"}},
"lifecycle": {{TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "passed"}},
results2: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "failed"},
"lifecycle": {TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "passed"},
},
expectedDiffReport: DiffReport{
Claim1ResultsSummary: TcResultsSummary{Passed: 1, Failed: 1},
Expand All @@ -279,13 +273,13 @@ func TestGetDiffReport(t *testing.T) {
},
{
description: "one same test case result and another different",
results1: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
"lifecycle": {{TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "failed"}},
results1: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
"lifecycle": {TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "failed"},
},
results2: map[string][]claim.TestCaseResult{
"access-control": {{TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"}},
"lifecycle": {{TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "skipped"}},
results2: map[string]claim.TestCaseResult{
"access-control": {TestID: claim.TestCaseID{ID: "access-control-ssh-daemons"}, State: "passed"},
"lifecycle": {TestID: claim.TestCaseID{ID: "lifecycle-pod-scheduling"}, State: "skipped"},
},
expectedDiffReport: DiffReport{
Claim1ResultsSummary: TcResultsSummary{Passed: 1, Failed: 1},
Expand Down
Loading
Loading