Skip to content

Commit

Permalink
test error when wrong device selected
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Jul 8, 2021
1 parent 94f7a0c commit f9a1ac3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tui/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (

"github.com/dundee/gdu/v5/internal/testanalyze"
"github.com/dundee/gdu/v5/internal/testapp"
"github.com/dundee/gdu/v5/internal/testdev"
"github.com/dundee/gdu/v5/internal/testdir"
"github.com/dundee/gdu/v5/pkg/analyze"
"github.com/dundee/gdu/v5/pkg/device"
"github.com/gdamore/tcell/v2"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -76,6 +78,32 @@ func TestDeviceSelected(t *testing.T) {
assert.Contains(t, ui.table.GetCell(0, 0).Text, "/..")
assert.Contains(t, ui.table.GetCell(1, 0).Text, "aaa")
}
func TestDeviceSelectedWithAnalyzeErr(t *testing.T) {
app := testapp.CreateMockedApp(false)
ui := CreateUI(app, true, true)
ui.done = make(chan struct{})
ui.SetIgnoreDirPaths([]string{"/xxx"})

devicesInfoMock := getDevicesInfoMock().(testdev.DevicesInfoGetterMock)

item3 := &device.Device{
Name: "xxx",
MountPoint: "/xxx",
Size: 1e12,
Free: 1e6,
}

devicesInfoMock.Devices = append(devicesInfoMock.Devices, item3)

err := ui.ListDevices(devicesInfoMock)

assert.Nil(t, err)
assert.Equal(t, 4, ui.table.GetRowCount())

ui.deviceItemSelected(3, 0) // select /xxx which does not exist

assert.True(t, ui.pages.HasPage("error"))
}

func TestAnalyzePath(t *testing.T) {
ui := getAnalyzedPathMockedApp(t, true, true, true)
Expand Down

0 comments on commit f9a1ac3

Please sign in to comment.