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:
Brendan Burns 2014-06-18 10:37:27 -07:00
parent f57ae2f4bf
commit 77dd0afc26
2 changed files with 5 additions and 0 deletions

View File

@ -78,6 +78,7 @@ func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) {
}
for _, pod := range machinePods {
if query.Matches(labels.Set(pod.Labels)) {
pod.CurrentState.Host = machine
pods = append(pods, pod)
}
}

View File

@ -354,6 +354,10 @@ func TestEtcdListPods(t *testing.T) {
if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" {
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) {