(t *testing.T)
| 760 | } |
| 761 | |
| 762 | func 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 | |
| 799 | func TestApplyCommonDaemonsetMetadata(t *testing.T) { |
| 800 | testCases := []struct { |
nothing calls this directly
no test coverage detected