aboutsummaryrefslogtreecommitdiffstats
path: root/logutil/logutil_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'logutil/logutil_test.go')
-rw-r--r--logutil/logutil_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/logutil/logutil_test.go b/logutil/logutil_test.go
new file mode 100644
index 0000000..29f8849
--- /dev/null
+++ b/logutil/logutil_test.go
@@ -0,0 +1,25 @@
+package logutil
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestWrite(t *testing.T) {
+ var sb strings.Builder
+ w := NewUniqueWriter(&sb)
+
+ w.Write([]byte("l1\n"))
+ w.Write([]byte("l1\n"))
+ w.Write([]byte("l2\n"))
+ w.Write([]byte("\n"))
+ w.Write([]byte("\n"))
+
+ want := "l1\n" +
+ "\033[1A\033[Kl1 [repeated 2 times]\n" +
+ "l2\n" +
+ "\n\033[1A\033[K[repeated 2 times]\n"
+ if got := sb.String(); got != want {
+ t.Errorf("got %q, want %q", got, want)
+ }
+}