|
| 1 | +/* |
| 2 | +Copyright 2016 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package leastnodes |
| 18 | + |
| 19 | +import ( |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/stretchr/testify/assert" |
| 23 | + |
| 24 | + "k8s.io/autoscaler/cluster-autoscaler/expander" |
| 25 | +) |
| 26 | + |
| 27 | +func TestLeastNodes(t *testing.T) { |
| 28 | + e := NewFilter() |
| 29 | + |
| 30 | + eo0 := expander.Option{Debug: "EO0", NodeCount: 2} |
| 31 | + ret := e.BestOptions([]expander.Option{eo0}, nil) |
| 32 | + assert.Equal(t, ret, []expander.Option{eo0}) |
| 33 | + |
| 34 | + eo1 := expander.Option{Debug: "EO1", NodeCount: 1} |
| 35 | + ret = e.BestOptions([]expander.Option{eo0, eo1}, nil) |
| 36 | + assert.Equal(t, ret, []expander.Option{eo1}) |
| 37 | + |
| 38 | + eo1b := expander.Option{Debug: "EO1b", NodeCount: 1} |
| 39 | + ret = e.BestOptions([]expander.Option{eo0, eo1, eo1b}, nil) |
| 40 | + assert.NotEqual(t, ret, []expander.Option{eo1}) |
| 41 | + assert.ObjectsAreEqual(ret, []expander.Option{eo1, eo1b}) |
| 42 | +} |
0 commit comments