@@ -6775,6 +6775,125 @@ func TestPrintScale(t *testing.T) {
6775
6775
}
6776
6776
}
6777
6777
6778
+ func TestPrintClusterTrustBundle (t * testing.T ) {
6779
+ tests := []struct {
6780
+ bundle certificates.ClusterTrustBundle
6781
+ options printers.GenerateOptions
6782
+ expected []metav1.TableRow
6783
+ }{
6784
+ {
6785
+ bundle : certificates.ClusterTrustBundle {
6786
+ ObjectMeta : metav1.ObjectMeta {
6787
+ Name : "test-cluster-trust-bundle" ,
6788
+ },
6789
+ Spec : certificates.ClusterTrustBundleSpec {
6790
+ SignerName : "test-signer-name" ,
6791
+ },
6792
+ },
6793
+ expected : []metav1.TableRow {
6794
+ {
6795
+ Cells : []interface {}{"test-cluster-trust-bundle" , "test-signer-name" },
6796
+ },
6797
+ },
6798
+ },
6799
+ }
6800
+
6801
+ for i , test := range tests {
6802
+ rows , err := printClusterTrustBundle (& test .bundle , test .options )
6803
+ if err != nil {
6804
+ t .Fatal (err )
6805
+ }
6806
+ for i := range rows {
6807
+ rows [i ].Object .Object = nil
6808
+ }
6809
+ if ! reflect .DeepEqual (test .expected , rows ) {
6810
+ t .Errorf ("%d mismatch: %s" , i , cmp .Diff (test .expected , rows ))
6811
+ }
6812
+ }
6813
+ }
6814
+
6815
+ func TestPrintValidatingAdmissionPolicyBinding (t * testing.T ) {
6816
+ tests := []struct {
6817
+ validatingAdmissionPolicyBinding admissionregistration.ValidatingAdmissionPolicyBinding
6818
+ options printers.GenerateOptions
6819
+ expected []metav1.TableRow
6820
+ }{
6821
+ {
6822
+ validatingAdmissionPolicyBinding : admissionregistration.ValidatingAdmissionPolicyBinding {
6823
+ ObjectMeta : metav1.ObjectMeta {
6824
+ Name : "config" ,
6825
+ CreationTimestamp : metav1.Time {Time : time .Now ().Add (- 3e11 )},
6826
+ },
6827
+ Spec : admissionregistration.ValidatingAdmissionPolicyBindingSpec {
6828
+ PolicyName : "test-scale.example.com" ,
6829
+ ParamRef : & admissionregistration.ParamRef {
6830
+ Name : "test-scale-setting.example.com" ,
6831
+ ParameterNotFoundAction : ptr .To (admissionregistration .DenyAction ),
6832
+ },
6833
+ },
6834
+ },
6835
+ expected : []metav1.TableRow {
6836
+ {
6837
+ Cells : []interface {}{"config" , "test-scale.example.com" , "*/test-scale-setting.example.com" , "5m" },
6838
+ },
6839
+ },
6840
+ },
6841
+ }
6842
+
6843
+ for i , test := range tests {
6844
+ rows , err := printValidatingAdmissionPolicyBinding (& test .validatingAdmissionPolicyBinding , test .options )
6845
+ if err != nil {
6846
+ t .Fatal (err )
6847
+ }
6848
+ for i := range rows {
6849
+ rows [i ].Object .Object = nil
6850
+ }
6851
+ if ! reflect .DeepEqual (test .expected , rows ) {
6852
+ t .Errorf ("%d mismatch: %s" , i , cmp .Diff (test .expected , rows ))
6853
+ }
6854
+ }
6855
+ }
6856
+
6857
+ func TestPrintLeaseCandidate (t * testing.T ) {
6858
+ tests := []struct {
6859
+ leaseCandidate coordination.LeaseCandidate
6860
+ options printers.GenerateOptions
6861
+ expected []metav1.TableRow
6862
+ }{
6863
+ {
6864
+ leaseCandidate : coordination.LeaseCandidate {
6865
+ ObjectMeta : metav1.ObjectMeta {
6866
+ Name : "test-lease" ,
6867
+ CreationTimestamp : metav1.Time {Time : time .Now ().Add (- 3e11 )},
6868
+ },
6869
+ Spec : coordination.LeaseCandidateSpec {
6870
+ BinaryVersion : "test-binary-version" ,
6871
+ EmulationVersion : "test-emulation-version" ,
6872
+ LeaseName : "test-lease-name" ,
6873
+ },
6874
+ },
6875
+ expected : []metav1.TableRow {
6876
+ {
6877
+ Cells : []interface {}{"test-lease" , "test-lease-name" , "test-binary-version" , "test-emulation-version" , "5m" },
6878
+ },
6879
+ },
6880
+ },
6881
+ }
6882
+
6883
+ for i , test := range tests {
6884
+ rows , err := printLeaseCandidate (& test .leaseCandidate , test .options )
6885
+ if err != nil {
6886
+ t .Fatal (err )
6887
+ }
6888
+ for i := range rows {
6889
+ rows [i ].Object .Object = nil
6890
+ }
6891
+ if ! reflect .DeepEqual (test .expected , rows ) {
6892
+ t .Errorf ("%d mismatch: %s" , i , cmp .Diff (test .expected , rows ))
6893
+ }
6894
+ }
6895
+ }
6896
+
6778
6897
func TestTableRowDeepCopyShouldNotPanic (t * testing.T ) {
6779
6898
tests := []struct {
6780
6899
name string
@@ -7092,6 +7211,18 @@ func TestTableRowDeepCopyShouldNotPanic(t *testing.T) {
7092
7211
return printResourceSlice (& resourceapis.ResourceSlice {}, printers.GenerateOptions {})
7093
7212
},
7094
7213
},
7214
+ {
7215
+ name : "LeaseCandidate" ,
7216
+ printer : func () ([]metav1.TableRow , error ) {
7217
+ return printLeaseCandidate (& coordination.LeaseCandidate {}, printers.GenerateOptions {})
7218
+ },
7219
+ },
7220
+ {
7221
+ name : "ClusterTrustBundle" ,
7222
+ printer : func () ([]metav1.TableRow , error ) {
7223
+ return printClusterTrustBundle (& certificates.ClusterTrustBundle {}, printers.GenerateOptions {})
7224
+ },
7225
+ },
7095
7226
}
7096
7227
7097
7228
for _ , test := range tests {
0 commit comments