From 6eaa5e24177c2acf89d40102eed241edc2206a7d Mon Sep 17 00:00:00 2001 From: Jorge Turrado Date: Fri, 10 Feb 2023 01:35:23 +0100 Subject: [PATCH] add unit tests Signed-off-by: Jorge Turrado --- pkg/util/http_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkg/util/http_test.go diff --git a/pkg/util/http_test.go b/pkg/util/http_test.go new file mode 100644 index 00000000000..f33da81192d --- /dev/null +++ b/pkg/util/http_test.go @@ -0,0 +1,36 @@ +/* +Copyright 2023 The KEDA 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 util + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestCreateHTTPClientWhenNegativeTimeout(t *testing.T) { + client := CreateHTTPClient(-1*time.Minute, false) + + assert.Equal(t, 300*time.Millisecond, client.Timeout) +} + +func TestCreateHTTPClientWhenValidTimeout(t *testing.T) { + client := CreateHTTPClient(1*time.Minute, false) + + assert.Equal(t, 1*time.Minute, client.Timeout) +}