INNER CODE UNIT · Go
fresh
Bharath-code/git-scope · internal/attention/attention_test.go:55
fresh := now.Add(-time.Hour)
tests := []struct {
name string
s model.RepoStatus
want bool
}{
{"dirty and old is stale", status(func(s *model.RepoStatus) { s.IsDirty = true; s.LastCommit = old }), true},
{"dirty and fresh not stale", status(func(s *model.RepoStatus) { s.IsDirty = true; s.LastCommit = fresh }), false},
{"clean and old not stale", status(func(s *model.RepoStatus) { s.LastCommit = old }), false},
{"exactly at threshold not stale", status(func(s *model.RepoStatus) {
s.IsDirty = true
s.LastCommit = now.Add(-StaleThreshold)
}), false},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if got := Stale(tc.s, now); got != tc.want {
t.Fatalf("Stale() = %v, want %v", got, tc.want)