Skip to content

Commit 2cb1018

Browse files
authored
prompt: support custom io (Reader/Writer) (#7)
1 parent 1e4dd55 commit 2cb1018

21 files changed

+666
-213
lines changed

mocks/prompt/mock_prompter.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

powerline/powerline_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func BenchmarkPowerlineRender(b *testing.B) {
5151
}
5252
}
5353

54-
func TestPowerlineRender(t *testing.T) {
54+
func TestPowerline_Render(t *testing.T) {
5555
segUser := &Segment{}
5656
segUser.SetContent("username")
5757
segUser.SetIcon("👤")

powerline/segment_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
)
1010

11-
func TestSegmentColor(t *testing.T) {
11+
func TestSegment_Color(t *testing.T) {
1212
s := Segment{}
1313

1414
c := s.Color()
@@ -30,15 +30,15 @@ func TestSegmentColor(t *testing.T) {
3030
assert.Equal(t, *s.color, c)
3131
}
3232

33-
func TestSegmentHasChanges(t *testing.T) {
33+
func TestSegment_HasChanges(t *testing.T) {
3434
s := Segment{}
3535
assert.False(t, s.HasChanges())
3636

3737
s.hasChanges = true
3838
assert.True(t, s.HasChanges())
3939
}
4040

41-
func TestSegmentRender(t *testing.T) {
41+
func TestSegment_Render(t *testing.T) {
4242
s := Segment{}
4343
assert.Equal(t, "", s.Render())
4444

@@ -66,7 +66,7 @@ func TestSegmentRender(t *testing.T) {
6666
assert.Equal(t, s.color.Sprint("[🌐 0.0.0.0]"), s.Render())
6767
}
6868

69-
func TestSegmentResetColor(t *testing.T) {
69+
func TestSegment_ResetColor(t *testing.T) {
7070
s := Segment{}
7171
s.SetColor(prompt.Color{
7272
Foreground: termenv.ANSI256Color(0),
@@ -78,7 +78,7 @@ func TestSegmentResetColor(t *testing.T) {
7878
assert.Nil(t, s.color)
7979
}
8080

81-
func TestSegmentSetColor(t *testing.T) {
81+
func TestSegment_SetColor(t *testing.T) {
8282
s := Segment{}
8383
s.SetContent("foo")
8484
s.hasChanges = false
@@ -108,7 +108,7 @@ func TestSegmentSetColor(t *testing.T) {
108108
assert.True(t, s.hasChanges)
109109
}
110110

111-
func TestSegmentSetContent(t *testing.T) {
111+
func TestSegment_SetContent(t *testing.T) {
112112
s := Segment{}
113113

114114
s.SetContent("foo", "tag1")
@@ -123,7 +123,7 @@ func TestSegmentSetContent(t *testing.T) {
123123
assert.False(t, s.HasChanges())
124124
}
125125

126-
func TestSegmentSetIcon(t *testing.T) {
126+
func TestSegment_SetIcon(t *testing.T) {
127127
s := Segment{}
128128
s.SetContent("foo")
129129
s.hasChanges = false
@@ -139,7 +139,7 @@ func TestSegmentSetIcon(t *testing.T) {
139139
assert.False(t, s.hasChanges)
140140
}
141141

142-
func TestSegmentWidth(t *testing.T) {
142+
func TestSegment_Width(t *testing.T) {
143143
s := Segment{}
144144
assert.Equal(t, 0, s.Width())
145145

prompt/auto_completer_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ func BenchmarkAutoComplete(b *testing.B) {
1919
}
2020
}
2121

22-
func TestSuggestionString(t *testing.T) {
23-
s := Suggestion{
24-
Value: "val",
25-
Hint: "hint",
26-
}
27-
assert.Equal(t, "val: hint", s.String())
28-
}
29-
3022
func TestAutoCompleteGoLangKeywords(t *testing.T) {
3123
ac := AutoCompleteGoLangKeywords()
3224

@@ -162,3 +154,11 @@ func TestAutoCompleteWords(t *testing.T) {
162154
assert.Equal(t, "foo", matches[2].Value)
163155
})
164156
}
157+
158+
func TestSuggestion_String(t *testing.T) {
159+
s := Suggestion{
160+
Value: "val",
161+
Hint: "hint",
162+
}
163+
assert.Equal(t, "val: hint", s.String())
164+
}

0 commit comments

Comments
 (0)