1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'master' into master

This commit is contained in:
C123R 2019-10-24 15:34:26 +02:00 committed by GitHub
commit 6a3a5ea7ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 12 deletions

8
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VictorAvelar/devto-api-go v1.0.0 github.com/VictorAvelar/devto-api-go v1.0.0
github.com/adlio/trello v1.4.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/andygrunwald/go-gerrit v0.0.0-20190825170856-5959a9bf9ff8
github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d
github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect
@ -45,12 +45,8 @@ require (
github.com/shirou/gopsutil v2.19.9+incompatible github.com/shirou/gopsutil v2.19.9+incompatible
github.com/sticreations/spotigopher v0.0.0-20181009182052-98632f6f94b0 github.com/sticreations/spotigopher v0.0.0-20181009182052-98632f6f94b0
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
<<<<<<< HEAD
github.com/wtfutil/todoist v0.0.1 github.com/wtfutil/todoist v0.0.1
======= github.com/xanzy/go-gitlab v0.21.0
github.com/wtfutil/todoist v0.0.0-20190913231042-97395e581a76
>>>>>>> 59b8877b... feat: Add new widget for football scores and standings
github.com/xanzy/go-gitlab v0.20.1
github.com/yfronto/newrelic v0.0.0-00010101000000-000000000000 github.com/yfronto/newrelic v0.0.0-00010101000000-000000000000
github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb
github.com/zorkian/go-datadog-api v2.24.0+incompatible github.com/zorkian/go-datadog-api v2.24.0+incompatible

4
go.sum
View File

@ -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/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 h1:1hKci+AyKOxJrugR9veaocu9DQGR2/GecI72BpaO0Rg=
github.com/alecthomas/chroma v0.6.7/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk= 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 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= 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= github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
@ -243,6 +245,8 @@ github.com/wtfutil/todoist v0.0.1 h1:E3srzocggLHme8zIEAEXXoY/fQZtFRjW69m4OiYv3hg
github.com/wtfutil/todoist v0.0.1/go.mod h1:YuuGLJSsTK6DGBD5Zaf3J8LSMfpEC2WtzYPey3XVOdI= 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 h1:+1BWDry84G5PzsnzG9DI4YjPbHeWKyouM0q0gfDPKgY=
github.com/xanzy/go-gitlab v0.20.1/go.mod h1:LSfUQ9OPDnwRqulJk2HcWaAiFfCzaknyeGvjQI67MbE= 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 h1:uWB0RGxBo7AToSJ3rvoCZhXtLw4U7XISXSezPewmfic=
github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb/go.mod h1:pHsWAmY9PfX7i/uwPZkmWrebc8JbK8FppKbvyevwzSU= 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= github.com/zorkian/go-datadog-api v2.24.0+incompatible h1:conz6t5Vu0nIVigLpinYudl6uYc+xhajR6WuX+tD21I=

View File

@ -51,7 +51,7 @@ func newTestGraph(graphStars int, graphIcon string) *BarGraph {
return &widget return &widget
} }
func TestNewBarGraph(t *testing.T) { func Test_NewBarGraph(t *testing.T) {
widget := newTestGraph(15, "|") widget := newTestGraph(15, "|")
assert.NotNil(t, widget.View) assert.NotNil(t, widget.View)
@ -59,7 +59,7 @@ func TestNewBarGraph(t *testing.T) {
assert.Equal(t, "|", widget.starChar) assert.Equal(t, "|", widget.starChar)
} }
func TestBuildBars(t *testing.T) { func Test_BuildBars(t *testing.T) {
widget := newTestGraph(15, "|") widget := newTestGraph(15, "|")
before := widget.View.GetText(false) before := widget.View.GetText(false)
@ -69,13 +69,13 @@ func TestBuildBars(t *testing.T) {
assert.NotEqual(t, before, after) assert.NotEqual(t, before, after)
} }
func TestTextView(t *testing.T) { func Test_TextView(t *testing.T) {
widget := newTestGraph(15, "|") widget := newTestGraph(15, "|")
assert.NotNil(t, widget.TextView()) assert.NotNil(t, widget.TextView())
} }
func TestBuildStars(t *testing.T) { func Test_BuildStars(t *testing.T) {
result := BuildStars(makeData(), 20, "*") result := BuildStars(makeData(), 20, "*")
assert.Equal(t, assert.Equal(t,
"Jun 27, 2018[[default]****[default] ] 20\nJul 09, 2018[[red]****************[default] ] 80\nJul 09, 2018[[green]****************[default] ] 80\n", "Jun 27, 2018[[default]****[default] ] 20\nJul 09, 2018[[red]****************[default] ] 80\nJul 09, 2018[[green]****************[default] ] 80\n",

View File

@ -5,6 +5,8 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/stretchr/testify/assert"
"github.com/wtfutil/wtf/cfg"
) )
func test() {} func test() {}
@ -13,7 +15,12 @@ func testKeyboardWidget() KeyboardWidget {
keyWid := NewKeyboardWidget( keyWid := NewKeyboardWidget(
tview.NewApplication(), tview.NewApplication(),
tview.NewPages(), tview.NewPages(),
nil, &cfg.Common{
Module: cfg.Module{
Name: "testWidget",
Type: "testType",
},
},
) )
return keyWid return keyWid
} }
@ -128,7 +135,7 @@ func Test_InputCapture(t *testing.T) {
expected: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone), expected: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
}, },
{ {
name: "with defined event", name: "with defined event and char handler",
before: func(keyWid KeyboardWidget) KeyboardWidget { before: func(keyWid KeyboardWidget) KeyboardWidget {
keyWid.SetKeyboardChar("a", test, "help") keyWid.SetKeyboardChar("a", test, "help")
return keyWid return keyWid
@ -136,6 +143,15 @@ func Test_InputCapture(t *testing.T) {
event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone), event: tcell.NewEventKey(tcell.KeyRune, 'a', tcell.ModNone),
expected: nil, 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 { 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() })
}