Skip to content

Commit

Permalink
docs: address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
caroldelwing committed Nov 20, 2024
1 parent 7070e37 commit e3e0598
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/cluster-scanner/internal/search_old_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions scripts/cluster-scanner/internal/search_old_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
})
}
Expand Down

0 comments on commit e3e0598

Please sign in to comment.