console: test dpaShortDigest's short-input guard
A digest of nine characters or fewer shows whole; ten or more shows as first four, an ellipsis and last four. Without the guard the short cases panic, which the test catches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+17
−0
internal/console/dparecord_test.go+17 −0
CI cancelled — superseded by a newer push — run details
Intent
Attributed to this commit: 22.4 g CO₂e (2,940,283 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on dpa-followups, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/dparecord_test.go b/internal/console/dparecord_test.go| index a84f6e854..c9b50342a 100644 |
| --- a/internal/console/dparecord_test.go |
| +++ b/internal/console/dparecord_test.go |
| @@ -130,3 +130,20 @@ func TestDPARecordNoneYet(t *testing.T) { |
| t.Fatalf("member without a record = %d, want the plain 404", ms) |
| } |
| } |
| + |
| +// TestDPAShortDigest: a digest longer than nine characters shows as its first |
| +// four, an ellipsis and its last four; a shorter one, which that would not |
| +// shorten, shows whole. |
| +func TestDPAShortDigest(t *testing.T) { |
| + for in, want := range map[string]string{ |
| + "": "", |
| + "abc": "abc", |
| + "abcdefghi": "abcdefghi", |
| + "abcdefghij": "abcd…ghij", |
| + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef": "0123…cdef", |
| + } { |
| + if got := dpaShortDigest(in); got != want { |
| + t.Errorf("dpaShortDigest(%q) = %q, want %q", in, got, want) |
| + } |
| + } |
| +} |