generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: conformance report summary field
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
- Loading branch information
Showing
4 changed files
with
151 additions
and
6 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
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
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
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,121 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package suite | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
confv1a1 "sigs.k8s.io/gateway-api/conformance/apis/v1alpha1" | ||
) | ||
|
||
func TestBuildSummary(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
report confv1a1.ProfileReport | ||
expectedSummary string | ||
}{ | ||
{ | ||
name: "core tests failed, no extended tests", | ||
report: confv1a1.ProfileReport{ | ||
Name: string(HTTPConformanceProfileName), | ||
Core: confv1a1.Status{ | ||
Result: confv1a1.Failure, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 5, | ||
Failed: 3, | ||
}, | ||
}, | ||
}, | ||
expectedSummary: "Core tests failed with 3 test failures.", | ||
}, | ||
{ | ||
name: "core tests succeded, extended tests failed", | ||
report: confv1a1.ProfileReport{ | ||
Name: string(HTTPConformanceProfileName), | ||
Core: confv1a1.Status{ | ||
Result: confv1a1.Success, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 8, | ||
}, | ||
}, | ||
Extended: &confv1a1.ExtendedStatus{ | ||
Status: confv1a1.Status{ | ||
Result: confv1a1.Failure, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 2, | ||
Failed: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectedSummary: "Core tests succeded. Extended tests failed with 1 test failures.", | ||
}, | ||
{ | ||
name: "core tests partially succeded, extended tests succeded", | ||
report: confv1a1.ProfileReport{ | ||
Name: string(HTTPConformanceProfileName), | ||
Core: confv1a1.Status{ | ||
Result: confv1a1.Partial, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 6, | ||
Skipped: 2, | ||
}, | ||
}, | ||
Extended: &confv1a1.ExtendedStatus{ | ||
Status: confv1a1.Status{ | ||
Result: confv1a1.Success, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 2, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectedSummary: "Core tests partially succeded with 2 test skips. Extended tests succeded.", | ||
}, | ||
{ | ||
name: "core tests succeded, extended tests partially succeded", | ||
report: confv1a1.ProfileReport{ | ||
Name: string(HTTPConformanceProfileName), | ||
Core: confv1a1.Status{ | ||
Result: confv1a1.Success, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 8, | ||
}, | ||
}, | ||
Extended: &confv1a1.ExtendedStatus{ | ||
Status: confv1a1.Status{ | ||
Result: confv1a1.Partial, | ||
Statistics: confv1a1.Statistics{ | ||
Passed: 2, | ||
Skipped: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectedSummary: "Core tests succeded. Extended tests partially succeded with 1 test skips.", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tc := tc | ||
summary := buildSummary(tc.report) | ||
require.Equal(t, tc.expectedSummary, summary) | ||
}) | ||
} | ||
} |