From e3e059884f4f0ae445a28b047815bf20037c603a Mon Sep 17 00:00:00 2001 From: Carolina Delwing Rosa Date: Tue, 19 Nov 2024 22:05:40 -0500 Subject: [PATCH] docs: address review suggestions --- scripts/cluster-scanner/internal/search_old_clusters.go | 2 +- .../cluster-scanner/internal/search_old_clusters_test.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/cluster-scanner/internal/search_old_clusters.go b/scripts/cluster-scanner/internal/search_old_clusters.go index f9fd30b..f648f5b 100644 --- a/scripts/cluster-scanner/internal/search_old_clusters.go +++ b/scripts/cluster-scanner/internal/search_old_clusters.go @@ -17,7 +17,7 @@ func SearchOldClusters(clusters []*models.V1SpectroClusterSummary) ([]string, er // Iterate through the clusters to find those running for more than 24 hours for _, cluster := range clusters { timeValue := time.Time(cluster.Metadata.CreationTimestamp) - clusterAge := time.Now().Sub(timeValue) + clusterAge := time.Since(timeValue) if clusterAge.Hours() >= 24 { age, err := GetFormattedAge(clusterAge) diff --git a/scripts/cluster-scanner/internal/search_old_clusters_test.go b/scripts/cluster-scanner/internal/search_old_clusters_test.go index 9997212..5871fff 100644 --- a/scripts/cluster-scanner/internal/search_old_clusters_test.go +++ b/scripts/cluster-scanner/internal/search_old_clusters_test.go @@ -16,6 +16,7 @@ type TestCaseSearch struct { func TestSearchOldClusters (t *testing.T) { now := time.Now() + parseTime := func (now time.Time, input string) time.Time { creationDate, _ := time.ParseDuration(input) age := now.Add(creationDate) @@ -96,16 +97,12 @@ func TestSearchOldClusters (t *testing.T) { t.Errorf("Lenghts mismatch. Got %v elements, want %v elements", len(clustersGot), len(value.output)) } for _, got := range clustersGot { - found := false for _, want := range value.output { if got == want { - found = true return } } - if !found { - t.Errorf("Got unexpected value %v, want %v", got, value.output) - } + t.Errorf("Got unexpected value %v, want %v", got, value.output) } }) }