Fix a bug in pod listing introduced in a recent refactor.
Add a test to catch a regression in the future.
This commit is contained in:
		@@ -78,6 +78,7 @@ func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		for _, pod := range machinePods {
 | 
							for _, pod := range machinePods {
 | 
				
			||||||
			if query.Matches(labels.Set(pod.Labels)) {
 | 
								if query.Matches(labels.Set(pod.Labels)) {
 | 
				
			||||||
 | 
									pod.CurrentState.Host = machine
 | 
				
			||||||
				pods = append(pods, pod)
 | 
									pods = append(pods, pod)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -354,6 +354,10 @@ func TestEtcdListPods(t *testing.T) {
 | 
				
			|||||||
	if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" {
 | 
						if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" {
 | 
				
			||||||
		t.Errorf("Unexpected pod list: %#v", pods)
 | 
							t.Errorf("Unexpected pod list: %#v", pods)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if pods[0].CurrentState.Host != "machine" ||
 | 
				
			||||||
 | 
							pods[1].CurrentState.Host != "machine" {
 | 
				
			||||||
 | 
							t.Errorf("Failed to populate host name.")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestEtcdListControllersNotFound(t *testing.T) {
 | 
					func TestEtcdListControllersNotFound(t *testing.T) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user