From 373e0f09bd3ea335301d5fa91e2dd02f6991d856 Mon Sep 17 00:00:00 2001 From: Ali Farah Date: Fri, 3 Jul 2020 01:08:04 +1000 Subject: [PATCH] Add unittest coverage for boottime_util_linux.go --- pkg/kubelet/util/BUILD | 1 + pkg/kubelet/util/bootime_util_linux_test.go | 36 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pkg/kubelet/util/bootime_util_linux_test.go diff --git a/pkg/kubelet/util/BUILD b/pkg/kubelet/util/BUILD index 5adac63deed..5f1b0099c23 100644 --- a/pkg/kubelet/util/BUILD +++ b/pkg/kubelet/util/BUILD @@ -9,6 +9,7 @@ load( go_test( name = "go_default_test", srcs = [ + "bootime_util_linux_test.go", "util_test.go", "util_unix_test.go", "util_windows_test.go", diff --git a/pkg/kubelet/util/bootime_util_linux_test.go b/pkg/kubelet/util/bootime_util_linux_test.go new file mode 100644 index 00000000000..99fcb293f41 --- /dev/null +++ b/pkg/kubelet/util/bootime_util_linux_test.go @@ -0,0 +1,36 @@ +// +build freebsd linux + +/* +Copyright 2018 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 util + +import ( + "testing" + "time" +) + +func TestGetBootTime(t *testing.T) { + boottime, err := GetBootTime() + + if err != nil { + t.Errorf("Unable to get system uptime") + } + + if !boottime.After(time.Time{}) { + t.Errorf("Invalid system uptime") + } +}