From 001ade48c9f896dd37172b512f41ac64965f32bd Mon Sep 17 00:00:00 2001 From: Krzysztof Jastrzebski Date: Tue, 12 Sep 2017 11:04:18 +0200 Subject: [PATCH] Core/autoscaling_context_test.go unit tests. --- .../core/autoscaling_context_test.go | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cluster-autoscaler/core/autoscaling_context_test.go diff --git a/cluster-autoscaler/core/autoscaling_context_test.go b/cluster-autoscaler/core/autoscaling_context_test.go new file mode 100644 index 0000000000..f4f6f337a9 --- /dev/null +++ b/cluster-autoscaler/core/autoscaling_context_test.go @@ -0,0 +1,42 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package core + +import ( + "testing" + + "k8s.io/autoscaler/cluster-autoscaler/clusterstate/utils" + "k8s.io/autoscaler/cluster-autoscaler/expander" + "k8s.io/autoscaler/cluster-autoscaler/simulator" + kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes" + + "github.com/stretchr/testify/assert" + "k8s.io/client-go/kubernetes/fake" + kube_record "k8s.io/client-go/tools/record" +) + +func TestNewAutoscalingContext(t *testing.T) { + fakeClient := &fake.Clientset{} + fakeRecorder := kube_record.NewFakeRecorder(5) + fakeLogRecorder, _ := utils.NewStatusMapRecorder(fakeClient, "kube-system", kube_record.NewFakeRecorder(5), false) + + autoscalingContext, err := NewAutoscalingContext(AutoscalingOptions{ExpanderName: expander.RandomExpanderName}, simulator.NewTestPredicateChecker(), + fakeClient, fakeRecorder, + fakeLogRecorder, kube_util.NewListerRegistry(nil, nil, nil, nil, nil, nil)) + assert.NoError(t, err) + assert.NotNil(t, autoscalingContext) +}