summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-09 08:34:51 +0300
committerPaul Buetow <paul@buetow.org>2026-04-09 08:34:51 +0300
commita4d5a70aa998b315e69d7a945a57ade083505011 (patch)
treeccf609fb76a2d2e4efb5f589ed948e2adf8d67e7 /main_test.go
parent034506aed7c3843143878fa0f5c9b99deef0d358 (diff)
Handle auto-log shared text loading
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
index 085dc24..8d6fac8 100644
--- a/main_test.go
+++ b/main_test.go
@@ -60,3 +60,56 @@ func TestLogEntryEmptyText(t *testing.T) {
t.Errorf("expected empty file, got %d bytes", len(content))
}
}
+
+func TestPrepareSharedTextLoadSkipsWhitespaceOnly(t *testing.T) {
+ mode, text, ok := prepareSharedTextLoad(" \n\t ", false)
+ if ok {
+ t.Fatal("expected whitespace-only text to be skipped")
+ }
+ if mode != sharedTextLoadPrefill {
+ t.Fatalf("expected prefill mode default, got %v", mode)
+ }
+ if text != "" {
+ t.Fatalf("expected empty text, got %q", text)
+ }
+}
+
+func TestPrepareSharedTextLoadPrefillMode(t *testing.T) {
+ mode, text, ok := prepareSharedTextLoad("hello", false)
+ if !ok {
+ t.Fatal("expected shared text to be accepted")
+ }
+ if mode != sharedTextLoadPrefill {
+ t.Fatalf("expected prefill mode, got %v", mode)
+ }
+ if text != "hello" {
+ t.Fatalf("expected original text, got %q", text)
+ }
+}
+
+func TestPrepareSharedTextLoadAutoLogMode(t *testing.T) {
+ mode, text, ok := prepareSharedTextLoad("hello", true)
+ if !ok {
+ t.Fatal("expected shared text to be accepted")
+ }
+ if mode != sharedTextLoadAutoLog {
+ t.Fatalf("expected auto-log mode, got %v", mode)
+ }
+ if text != "hello" {
+ t.Fatalf("expected original text, got %q", text)
+ }
+}
+
+func TestPrepareSharedTextLoadAllowsLongText(t *testing.T) {
+ text := strings.Repeat("x", maxTextLength+1)
+ mode, gotText, ok := prepareSharedTextLoad(text, true)
+ if !ok {
+ t.Fatal("expected long shared text to be accepted")
+ }
+ if mode != sharedTextLoadAutoLog {
+ t.Fatalf("expected auto-log mode, got %v", mode)
+ }
+ if gotText != text {
+ t.Fatalf("expected original text to be preserved, got %d bytes", len(gotText))
+ }
+}