Browse Source

Coverage of bar UpdateP.

Steve Thielemann 3 years ago
parent
commit
1bda710321
1 changed files with 10 additions and 1 deletions
  1. 10 1
      door/bar_test.go

+ 10 - 1
door/bar_test.go

@@ -4,6 +4,12 @@ import (
 	"testing"
 )
 
+func pctUpdate(pct *int64) func() int64 {
+	return func() int64 {
+		return *pct
+	}
+}
+
 func TestBarHalfStep(t *testing.T) {
 
 	// This is normally done by door init, but we're skipping that right now
@@ -67,8 +73,11 @@ func TestBarHalfStep(t *testing.T) {
 		100: BarColor + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
 	}
 
+	var percent int64
+	bar.UpdateP = pctUpdate(&percent)
+
 	for pct, text := range BarGrad {
-		bar.Percent = int64(pct * 100)
+		percent = int64(pct * 100)
 		got := bar.Output()
 		if got != text {
 			t.Errorf("BarGradient: Expected %#v (%d%%), got %#v", text, pct, got)