Skip to content

Commit 3fa3c1d

Browse files
committed
unit test case for isPagerEnabled
1 parent e39721f commit 3fa3c1d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/schema/schema_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,36 @@ schemas:
3636
assert.Equal(t, "some/random/path", schemas.Manifest)
3737
assert.Equal(t, []string{"hello", "world"}, schemas.Matches)
3838
}
39+
40+
func TestIsPagerEnabled(t *testing.T) {
41+
tests := []struct {
42+
name string
43+
pager string
44+
expect bool
45+
}{
46+
{"Empty string should enable pager", "", true},
47+
{"'on' should enable pager", "on", true},
48+
{"'less' should enable pager", "less", true},
49+
{"'true' should enable pager", "true", true},
50+
{"'yes' should enable pager", "yes", true},
51+
{"'y' should enable pager", "y", true},
52+
{"'1' should enable pager", "1", true},
53+
{"'off' should disable pager", "off", false},
54+
{"'false' should disable pager", "false", false},
55+
{"'no' should disable pager", "no", false},
56+
{"'n' should disable pager", "n", false},
57+
{"'0' should disable pager", "0", false},
58+
{"Random string should disable pager", "random", false},
59+
{"Capitalized 'ON' should disable pager (case sensitive)", "ON", false},
60+
}
61+
62+
for _, tt := range tests {
63+
t.Run(tt.name, func(t *testing.T) {
64+
term := &Terminal{Pager: tt.pager}
65+
result := term.IsPagerEnabled()
66+
if result != tt.expect {
67+
t.Errorf("IsPagerEnabled() for Pager=%q: expected %v, got %v", tt.pager, tt.expect, result)
68+
}
69+
})
70+
}
71+
}

0 commit comments

Comments
 (0)