INNER CODE UNIT · Go

TestClassify

Bharath-code/git-scope · internal/attention/attention_test.go:20

func TestClassify(t *testing.T) {
	tests := []struct {
		name string
		s    model.RepoStatus
		want Tier
	}{
		{"empty is clean", status(nil), Clean},
		{"ahead is action", status(func(s *model.RepoStatus) { s.Ahead = 1 }), Action},
		{"behind is action", status(func(s *model.RepoStatus) { s.Behind = 1 }), Action},
		{"diverged is action", status(func(s *model.RepoStatus) { s.Ahead = 2; s.Behind = 3 }), Action},
		{"scan error is action", status(func(s *model.RepoStatus) { s.ScanError = "boom" }), Action},
		{"dirty in sync is watch", status(func(s *model.RepoStatus) { s.IsDirty = true; s.Unstaged = 1 }), Watch},
		{"staged in sync is watch", status(func(s *model.RepoStatus) { s.IsDirty = true; s.Staged = 2 }), Watch},
		{"ahead beats dirty -> action", status(func(s *model.RepoStatus) { s.IsDirty = true; s.Ahead = 1 }), Action},
	}
	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			if got := Classify(tc.s, now); got != tc.want {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…