MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / TestApplyHostNetworkConfig

Function TestApplyHostNetworkConfig

controllers/transforms_test.go:762–797  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

760}
761
762func TestApplyHostNetworkConfig(t *testing.T) {
763 tests := []struct {
764 name string
765 hostNetwork *bool
766 expectEnabled bool
767 expectDNSPolicy corev1.DNSPolicy
768 }{
769 {
770 name: "hostNetwork nil, should not set hostNetwork",
771 hostNetwork: nil,
772 expectEnabled: false,
773 expectDNSPolicy: "",
774 },
775 {
776 name: "hostNetwork true, should set hostNetwork and DNSPolicy",
777 hostNetwork: ptr.To(true),
778 expectEnabled: true,
779 expectDNSPolicy: corev1.DNSClusterFirstWithHostNet,
780 },
781 {
782 name: "hostNetwork false, should not set hostNetwork",
783 hostNetwork: ptr.To(false),
784 expectEnabled: false,
785 expectDNSPolicy: "",
786 },
787 }
788
789 for _, tt := range tests {
790 t.Run(tt.name, func(t *testing.T) {
791 podSpec := &corev1.PodSpec{}
792 applyHostNetworkConfig(podSpec, tt.hostNetwork)
793 require.Equal(t, tt.expectEnabled, podSpec.HostNetwork)
794 require.Equal(t, tt.expectDNSPolicy, podSpec.DNSPolicy)
795 })
796 }
797}
798
799func TestApplyCommonDaemonsetMetadata(t *testing.T) {
800 testCases := []struct {

Callers

nothing calls this directly

Calls 2

applyHostNetworkConfigFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected