@@ -727,6 +727,94 @@ func TestPrintNodeStatus(t *testing.T) {
727
727
}
728
728
}
729
729
730
+ func TestPrintNodeOSImage (t * testing.T ) {
731
+ printer := NewHumanReadablePrinter (PrintOptions {
732
+ ColumnLabels : []string {},
733
+ Wide : true ,
734
+ })
735
+
736
+ table := []struct {
737
+ node api.Node
738
+ osImage string
739
+ }{
740
+ {
741
+ node : api.Node {
742
+ ObjectMeta : api.ObjectMeta {Name : "foo1" },
743
+ Status : api.NodeStatus {
744
+ NodeInfo : api.NodeSystemInfo {OSImage : "fake-os-image" },
745
+ Addresses : []api.NodeAddress {{Type : api .NodeExternalIP , Address : "1.1.1.1" }},
746
+ },
747
+ },
748
+ osImage : "fake-os-image" ,
749
+ },
750
+ {
751
+ node : api.Node {
752
+ ObjectMeta : api.ObjectMeta {Name : "foo2" },
753
+ Status : api.NodeStatus {
754
+ NodeInfo : api.NodeSystemInfo {KernelVersion : "fake-kernel-version" },
755
+ Addresses : []api.NodeAddress {{Type : api .NodeExternalIP , Address : "1.1.1.1" }},
756
+ },
757
+ },
758
+ osImage : "<unknown>" ,
759
+ },
760
+ }
761
+
762
+ for _ , test := range table {
763
+ buffer := & bytes.Buffer {}
764
+ err := printer .PrintObj (& test .node , buffer )
765
+ if err != nil {
766
+ t .Fatalf ("An error occurred printing Node: %#v" , err )
767
+ }
768
+ if ! contains (strings .Fields (buffer .String ()), test .osImage ) {
769
+ t .Fatalf ("Expect printing node %s with os image %#v, got: %#v" , test .node .Name , test .osImage , buffer .String ())
770
+ }
771
+ }
772
+ }
773
+
774
+ func TestPrintNodeKernelVersion (t * testing.T ) {
775
+ printer := NewHumanReadablePrinter (PrintOptions {
776
+ ColumnLabels : []string {},
777
+ Wide : true ,
778
+ })
779
+
780
+ table := []struct {
781
+ node api.Node
782
+ kernelVersion string
783
+ }{
784
+ {
785
+ node : api.Node {
786
+ ObjectMeta : api.ObjectMeta {Name : "foo1" },
787
+ Status : api.NodeStatus {
788
+ NodeInfo : api.NodeSystemInfo {KernelVersion : "fake-kernel-version" },
789
+ Addresses : []api.NodeAddress {{Type : api .NodeExternalIP , Address : "1.1.1.1" }},
790
+ },
791
+ },
792
+ kernelVersion : "fake-kernel-version" ,
793
+ },
794
+ {
795
+ node : api.Node {
796
+ ObjectMeta : api.ObjectMeta {Name : "foo2" },
797
+ Status : api.NodeStatus {
798
+ NodeInfo : api.NodeSystemInfo {OSImage : "fake-os-image" },
799
+ Addresses : []api.NodeAddress {{Type : api .NodeExternalIP , Address : "1.1.1.1" }},
800
+ },
801
+ },
802
+ kernelVersion : "<unknown>" ,
803
+ },
804
+ }
805
+
806
+ for _ , test := range table {
807
+ buffer := & bytes.Buffer {}
808
+ err := printer .PrintObj (& test .node , buffer )
809
+ if err != nil {
810
+ t .Fatalf ("An error occurred printing Node: %#v" , err )
811
+ }
812
+ if ! contains (strings .Fields (buffer .String ()), test .kernelVersion ) {
813
+ t .Fatalf ("Expect printing node %s with kernel version %#v, got: %#v" , test .node .Name , test .kernelVersion , buffer .String ())
814
+ }
815
+ }
816
+ }
817
+
730
818
func TestPrintNodeExternalIP (t * testing.T ) {
731
819
printer := NewHumanReadablePrinter (PrintOptions {
732
820
Wide : true ,
0 commit comments