mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	fix up test for setting default namespace labels
This commit is contained in:
		@@ -1417,9 +1417,6 @@ func TestSetDefaultNamespace(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSetDefaultNamespaceLabels(t *testing.T) {
 | 
			
		||||
	// Although this is defaulted to true, it's still worth to enable the feature gate during the test
 | 
			
		||||
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NamespaceDefaultLabelName, true)()
 | 
			
		||||
 | 
			
		||||
	theNs := "default-ns-labels-are-great"
 | 
			
		||||
	s := &v1.Namespace{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
@@ -1432,22 +1429,6 @@ func TestSetDefaultNamespaceLabels(t *testing.T) {
 | 
			
		||||
	if s2.ObjectMeta.Labels[v1.LabelMetadataName] != theNs {
 | 
			
		||||
		t.Errorf("Expected default namespace label value of %v, but got %v", theNs, s2.ObjectMeta.Labels[v1.LabelMetadataName])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// And let's disable the FG and check if it still defaults creating the labels
 | 
			
		||||
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NamespaceDefaultLabelName, false)()
 | 
			
		||||
 | 
			
		||||
	theNs = "default-ns-labels-are-not-that-great"
 | 
			
		||||
	s = &v1.Namespace{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
			Name: theNs,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	obj2 = roundTrip(t, runtime.Object(s))
 | 
			
		||||
	s2 = obj2.(*v1.Namespace)
 | 
			
		||||
 | 
			
		||||
	if _, ok := s2.ObjectMeta.Labels[v1.LabelMetadataName]; ok {
 | 
			
		||||
		t.Errorf("Default namespace shouldn't exist here, as the feature gate is disabled %v", s)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user