func TestFiltering(t *testing.T) { ctx := api.NewContext() mockMinionRegistry := registrytest.NewMinionRegistry([]string{"m1", "m2", "m3"}, api.NodeResources{}) healthy := NewHealthyRegistry( mockMinionRegistry, ¬Minion{minion: "m1"}, &util.FakeClock{}, 60*time.Second, ) expected := []string{"m1", "m2", "m3"} list, err := healthy.ListMinions(ctx) if err != nil { t.Errorf("unexpected error: %v", err) } expectedMinions := registrytest.MakeMinionList(expected, api.NodeResources{}) expectedMinions.Items[0].Status.Conditions = []api.NodeCondition{{Kind: api.NodeReady, Status: api.ConditionNone}} expectedMinions.Items[1].Status.Conditions = []api.NodeCondition{{Kind: api.NodeReady, Status: api.ConditionFull}} expectedMinions.Items[2].Status.Conditions = []api.NodeCondition{{Kind: api.NodeReady, Status: api.ConditionFull}} if !reflect.DeepEqual(list, expectedMinions) { t.Errorf("Expected %v, Got %v", expected, list) } minion, err := healthy.GetMinion(ctx, "m1") if err != nil { t.Errorf("unexpected error: %v", err) } if minion == nil { t.Errorf("Unexpected empty 'm1'") } }
func TestFiltering(t *testing.T) { ctx := api.NewContext() mockMinionRegistry := registrytest.NewMinionRegistry([]string{"m1", "m2", "m3"}, api.NodeResources{}) healthy := HealthyRegistry{ delegate: mockMinionRegistry, client: ¬Minion{minion: "m1"}, } expected := []string{"m2", "m3"} list, err := healthy.ListMinions(ctx) if err != nil { t.Errorf("unexpected error: %v", err) } if !reflect.DeepEqual(list, registrytest.MakeMinionList(expected, api.NodeResources{})) { t.Errorf("Expected %v, Got %v", expected, list) } minion, err := healthy.GetMinion(ctx, "m1") if err == nil { t.Errorf("unexpected non-error") } if minion != nil { t.Errorf("Unexpected presence of 'm1'") } }