From b9340968329f74dcbf8d608812a0e76beba1173e Mon Sep 17 00:00:00 2001 From: hmuar <1871299+hmuar@users.noreply.github.com> Date: Tue, 22 Oct 2019 23:52:58 -0700 Subject: [PATCH 1/4] add tests for keyboard_widget --- view/keyboard_widget_test.go | 60 ++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/view/keyboard_widget_test.go b/view/keyboard_widget_test.go index c1540850..b21a2733 100644 --- a/view/keyboard_widget_test.go +++ b/view/keyboard_widget_test.go @@ -5,6 +5,8 @@ import ( "github.com/gdamore/tcell" "github.com/rivo/tview" + "github.com/stretchr/testify/assert" + "github.com/wtfutil/wtf/cfg" ) func test() {} @@ -13,7 +15,12 @@ func testKeyboardWidget() KeyboardWidget { keyWid := NewKeyboardWidget( tview.NewApplication(), tview.NewPages(), - nil, + &cfg.Common{ + Module: cfg.Module{ + Name: "testWidget", + Type: "testType", + }, + }, ) return keyWid } @@ -128,7 +135,7 @@ func Test_InputCapture(t *testing.T) { expected: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone), }, { - name: "with defined event", + name: "with defined event and char handler", before: func(keyWid KeyboardWidget) KeyboardWidget { keyWid.SetKeyboardChar("a", test, "help") return keyWid @@ -136,6 +143,15 @@ func Test_InputCapture(t *testing.T) { event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone), expected: nil, }, + { + name: "with defined event and key handler", + before: func(keyWid KeyboardWidget) KeyboardWidget { + keyWid.SetKeyboardKey(tcell.KeyRune, test, "help") + return keyWid + }, + event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone), + expected: nil, + }, } for _, tt := range tests { @@ -157,3 +173,43 @@ func Test_InputCapture(t *testing.T) { }) } } + +func Test_InitializeCommonControls(t *testing.T) { + t.Run("nil refreshFunc", func(t *testing.T) { + keyWid := testKeyboardWidget() + keyWid.InitializeCommonControls(nil) + + assert.NotNil(t, keyWid.charMap["/"]) + assert.Nil(t, keyWid.charMap["r"]) + }) + + t.Run("non-nil refreshFunc", func(t *testing.T) { + keyWid := testKeyboardWidget() + keyWid.InitializeCommonControls(func() {}) + + assert.NotNil(t, keyWid.charMap["r"]) + }) +} + +func Test_HelpText(t *testing.T) { + keyWid := testKeyboardWidget() + keyWid.SetKeyboardChar("a", test, "a help") + keyWid.SetKeyboardKey(tcell.KeyCtrlO, test, "keyCtrlO help") + + assert.NotNil(t, keyWid.HelpText()) +} + +func Test_SetView(t *testing.T) { + keyWid := testKeyboardWidget() + assert.Nil(t, keyWid.view) + + view := &tview.TextView{} + keyWid.SetView(view) + assert.Equal(t, view, keyWid.view) +} + +func Test_ShowHelp(t *testing.T) { + keyWid := testKeyboardWidget() + + assert.NotPanics(t, func() { keyWid.ShowHelp() }) +} From 20e30fdefc9bec40bd4d2880d6252966d95d827c Mon Sep 17 00:00:00 2001 From: hmuar <1871299+hmuar@users.noreply.github.com> Date: Tue, 22 Oct 2019 23:53:21 -0700 Subject: [PATCH 2/4] rename tests to be consistent with other test files --- view/bargraph_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/view/bargraph_test.go b/view/bargraph_test.go index 1673102a..9d7180ee 100644 --- a/view/bargraph_test.go +++ b/view/bargraph_test.go @@ -51,7 +51,7 @@ func newTestGraph(graphStars int, graphIcon string) *BarGraph { return &widget } -func TestNewBarGraph(t *testing.T) { +func Test_NewBarGraph(t *testing.T) { widget := newTestGraph(15, "|") assert.NotNil(t, widget.View) @@ -59,7 +59,7 @@ func TestNewBarGraph(t *testing.T) { assert.Equal(t, "|", widget.starChar) } -func TestBuildBars(t *testing.T) { +func Test_BuildBars(t *testing.T) { widget := newTestGraph(15, "|") before := widget.View.GetText(false) @@ -69,13 +69,13 @@ func TestBuildBars(t *testing.T) { assert.NotEqual(t, before, after) } -func TestTextView(t *testing.T) { +func Test_TextView(t *testing.T) { widget := newTestGraph(15, "|") assert.NotNil(t, widget.TextView()) } -func TestBuildStars(t *testing.T) { +func Test_BuildStars(t *testing.T) { result := BuildStars(makeData(), 20, "*") assert.Equal(t, "Jun 27, 2018[[default]****[default] ] 20\nJul 09, 2018[[red]****************[default] ] 80\nJul 09, 2018[[green]****************[default] ] 80\n", From 54c07396744c1ca419c8a5834eb7cfee951623c2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2019 06:45:56 +0000 Subject: [PATCH 3/4] Bump github.com/alecthomas/chroma from 0.6.7 to 0.6.8 Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.6.7 to 0.6.8. - [Release notes](https://github.com/alecthomas/chroma/releases) - [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml) - [Commits](https://github.com/alecthomas/chroma/compare/v0.6.7...v0.6.8) Signed-off-by: dependabot-preview[bot] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index eb187024..78631178 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect github.com/VictorAvelar/devto-api-go v1.0.0 github.com/adlio/trello v1.4.0 - github.com/alecthomas/chroma v0.6.7 + github.com/alecthomas/chroma v0.6.8 github.com/andygrunwald/go-gerrit v0.0.0-20190825170856-5959a9bf9ff8 github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d github.com/cenkalti/backoff v2.2.1+incompatible // indirect diff --git a/go.sum b/go.sum index 60032bf6..1c446426 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= github.com/alecthomas/chroma v0.6.7 h1:1hKci+AyKOxJrugR9veaocu9DQGR2/GecI72BpaO0Rg= github.com/alecthomas/chroma v0.6.7/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk= +github.com/alecthomas/chroma v0.6.8 h1:TW4JJaIdbAbMyUtGEd6BukFlOKYvVQz3vVhLBEUNwMU= +github.com/alecthomas/chroma v0.6.8/go.mod h1:o9ohftueRi7H5be3+Q2cQCNa/YnLBFUNx40ZJfGVFKA= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= From 3c21afef6dbf18fd0012e6575745a854f2d15ff6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2019 06:46:25 +0000 Subject: [PATCH 4/4] Bump github.com/xanzy/go-gitlab from 0.20.1 to 0.21.0 Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.20.1 to 0.21.0. - [Release notes](https://github.com/xanzy/go-gitlab/releases) - [Changelog](https://github.com/xanzy/go-gitlab/blob/master/CHANGELOG.md) - [Commits](https://github.com/xanzy/go-gitlab/compare/v0.20.1...v0.21.0) Signed-off-by: dependabot-preview[bot] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index eb187024..ef152b50 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/sticreations/spotigopher v0.0.0-20181009182052-98632f6f94b0 github.com/stretchr/testify v1.4.0 github.com/wtfutil/todoist v0.0.1 - github.com/xanzy/go-gitlab v0.20.1 + github.com/xanzy/go-gitlab v0.21.0 github.com/yfronto/newrelic v0.0.0-00010101000000-000000000000 github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb github.com/zorkian/go-datadog-api v2.24.0+incompatible diff --git a/go.sum b/go.sum index 60032bf6..dc07d029 100644 --- a/go.sum +++ b/go.sum @@ -242,6 +242,8 @@ github.com/wtfutil/todoist v0.0.1 h1:E3srzocggLHme8zIEAEXXoY/fQZtFRjW69m4OiYv3hg github.com/wtfutil/todoist v0.0.1/go.mod h1:YuuGLJSsTK6DGBD5Zaf3J8LSMfpEC2WtzYPey3XVOdI= github.com/xanzy/go-gitlab v0.20.1 h1:+1BWDry84G5PzsnzG9DI4YjPbHeWKyouM0q0gfDPKgY= github.com/xanzy/go-gitlab v0.20.1/go.mod h1:LSfUQ9OPDnwRqulJk2HcWaAiFfCzaknyeGvjQI67MbE= +github.com/xanzy/go-gitlab v0.21.0 h1:Ru55sR4TBoDNsAKwCOpzeaGtbiWj7xTksVmzBJbLu6c= +github.com/xanzy/go-gitlab v0.21.0/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2HagfWKv5Og= github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb h1:uWB0RGxBo7AToSJ3rvoCZhXtLw4U7XISXSezPewmfic= github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb/go.mod h1:pHsWAmY9PfX7i/uwPZkmWrebc8JbK8FppKbvyevwzSU= github.com/zorkian/go-datadog-api v2.24.0+incompatible h1:conz6t5Vu0nIVigLpinYudl6uYc+xhajR6WuX+tD21I=