Skip to content

Commit 6829889

Browse files
authored
Fixes for certsuite claim compare UTs. (redhat-best-practices-for-k8s#2455)
Some UTs were commented on commit 62f679d, so this commit uncomment and fixes them. Also, supported claim schema has been switched to v0.5.0
1 parent a0c63de commit 6829889

File tree

7 files changed

+59
-53
lines changed

7 files changed

+59
-53
lines changed

cmd/certsuite/claim/compare/compare_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package compare
22

3-
/*
3+
import (
4+
"io"
5+
"os"
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
411
func Test_claimCompareFilesfunc(t *testing.T) {
512
testCases := []struct {
613
name string
@@ -93,4 +100,3 @@ func Test_claimCompareFilesfunc(t *testing.T) {
93100
})
94101
}
95102
}
96-
*/

cmd/certsuite/claim/compare/testdata/claim_access_control.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"checkDiscoveredContainerCertificationStatus": false,
2929
"collectorAppEndPoint": "http://localhost:8080",
3030
"collectorAppPassword": "test-password",
31-
"probeDaemonSetNamespace": "custom-probepods-ns",
31+
"probeDaemonSetNamespace": "different-probepods-ns",
3232
"executedBy": "default-executed-by",
3333
"managedDeployments": [
3434
{

cmd/certsuite/claim/compare/testdata/diff1.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
VERSIONS: Differences
2-
FIELD CLAIM 1 CLAIM 2
3-
/k8s v1.26.4+c343423 v1.26.3+b404935
4-
/ocp 4.13.1 4.13.0
2+
FIELD CLAIM 1 CLAIM 2
53
/certSuiteGitCommit 1b968e53b79fd8e81e48b761c3efd7a808d4567e 20641f745f65aaba24d9f5105f6dee531f67fc37
4+
/k8s v1.26.4+c343423 v1.26.3+b404935
5+
/ocp 4.13.1 4.13.0
66

77
VERSIONS: Only in CLAIM 1
88
<none>
@@ -56,7 +56,7 @@ CONFIGURATIONS
5656

5757
Cert Suite Configuration: Differences
5858
FIELD CLAIM 1 CLAIM 2
59-
/probeDaemonSetNamespace custom-probepods-ns cnf-suite
59+
/probeDaemonSetNamespace custom-probepods-ns different-probepods-ns
6060

6161
Cert Suite Configuration: Only in CLAIM 1
6262
<none>

cmd/certsuite/claim/compare/testdata/diff1_reverse.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
VERSIONS: Differences
2-
FIELD CLAIM 1 CLAIM 2
3-
/k8s v1.26.3+b404935 v1.26.4+c343423
4-
/ocp 4.13.0 4.13.1
2+
FIELD CLAIM 1 CLAIM 2
53
/certSuiteGitCommit 20641f745f65aaba24d9f5105f6dee531f67fc37 1b968e53b79fd8e81e48b761c3efd7a808d4567e
4+
/k8s v1.26.3+b404935 v1.26.4+c343423
5+
/ocp 4.13.0 4.13.1
66

77
VERSIONS: Only in CLAIM 1
88
<none>
@@ -54,14 +54,14 @@ observability-termination-policy skipped failed
5454
CONFIGURATIONS
5555
--------------
5656

57-
CNF Cert Suite Configuration: Differences
58-
FIELD CLAIM 1 CLAIM 2
59-
/probeDaemonSetNamespace cnf-suite custom-probepods-ns
57+
Cert Suite Configuration: Differences
58+
FIELD CLAIM 1 CLAIM 2
59+
/probeDaemonSetNamespace different-probepods-ns custom-probepods-ns
6060

61-
CNF Cert Suite Configuration: Only in CLAIM 1
61+
Cert Suite Configuration: Only in CLAIM 1
6262
/targetNameSpaces/1=test-ns
6363

64-
CNF Cert Suite Configuration: Only in CLAIM 2
64+
Cert Suite Configuration: Only in CLAIM 2
6565
<none>
6666

6767
Cluster abnormal events count

cmd/certsuite/claim/compare/versions/versions_test.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,43 +78,43 @@ func TestCompare(t *testing.T) {
7878
},
7979
},
8080
}},
81-
}, /*
82-
{
83-
name: "non matching versions 2",
84-
args: args{
85-
claim1Versions: &officialClaimScheme.Versions{
86-
ClaimFormat: "1",
87-
K8s: "22AAA",
88-
OcClient: "333",
89-
Ocp: "4444",
90-
CertSuite: "55555",
91-
CertSuiteGitCommit: "666666",
81+
},
82+
{
83+
name: "non matching versions 2",
84+
args: args{
85+
claim1Versions: &officialClaimScheme.Versions{
86+
ClaimFormat: "1",
87+
K8s: "22AAA",
88+
OcClient: "333",
89+
Ocp: "4444",
90+
CertSuite: "55555",
91+
CertSuiteGitCommit: "666666",
92+
},
93+
claim2Versions: &officialClaimScheme.Versions{
94+
ClaimFormat: "1",
95+
K8s: "22",
96+
OcClient: "333",
97+
Ocp: "4444",
98+
CertSuite: "55555BBBB",
99+
CertSuiteGitCommit: "666666",
100+
},
101+
},
102+
want: &DiffReport{Diffs: &diff.Diffs{
103+
Name: "VERSIONS",
104+
Fields: []diff.FieldDiff{
105+
{
106+
FieldPath: "/certSuite",
107+
Claim1Value: "55555",
108+
Claim2Value: "55555BBBB",
92109
},
93-
claim2Versions: &officialClaimScheme.Versions{
94-
ClaimFormat: "1",
95-
K8s: "22",
96-
OcClient: "333",
97-
Ocp: "4444",
98-
CertSuite: "55555BBBB",
99-
CertSuiteGitCommit: "666666",
110+
{
111+
FieldPath: "/k8s",
112+
Claim1Value: "22AAA",
113+
Claim2Value: "22",
100114
},
101115
},
102-
want: &DiffReport{Diffs: &diff.Diffs{
103-
Name: "VERSIONS",
104-
Fields: []diff.FieldDiff{
105-
{
106-
FieldPath: "/k8s",
107-
Claim1Value: "22AAA",
108-
Claim2Value: "22",
109-
},
110-
{
111-
FieldPath: "/certSuite",
112-
Claim1Value: "55555",
113-
Claim2Value: "55555BBBB",
114-
},
115-
},
116-
}},
117-
},*/
116+
}},
117+
},
118118
}
119119
for _, tc := range tests {
120120
t.Run(tc.name, func(t *testing.T) {

cmd/certsuite/pkg/claim/claim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
const (
13-
supportedClaimFormatVersion = "v0.4.0"
13+
supportedClaimFormatVersion = "v0.5.0"
1414
)
1515

1616
const (

cmd/certsuite/pkg/claim/claim_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ func TestIsClaimFormatVersionSupported(t *testing.T) {
2222
},
2323
{
2424
claimFormatVersion: "v0.0.0",
25-
expectedError: "claim format version v0.0.0 is not supported. Supported version is v0.4.0",
25+
expectedError: "claim format version v0.0.0 is not supported. Supported version is v0.5.0",
2626
},
2727
{
2828
claimFormatVersion: "v0.0.1",
29-
expectedError: "claim format version v0.0.1 is not supported. Supported version is v0.4.0",
29+
expectedError: "claim format version v0.0.1 is not supported. Supported version is v0.5.0",
3030
},
3131
{
32-
claimFormatVersion: "v0.4.0",
32+
claimFormatVersion: "v0.5.0",
3333
expectedError: "",
3434
},
3535
}

0 commit comments

Comments
 (0)