Skip to content

Commit

Permalink
test: fix storage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Apr 24, 2024
1 parent 81f40a2 commit 79642ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions cmd/gdu/app/app_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ func TestUseStorage(t *testing.T) {
fin := testdir.CreateTestDir()
defer fin()

const storagePath = "/tmp/badger-test"
defer func() {
err := os.RemoveAll("/tmp/badger-test")
err := os.RemoveAll(storagePath)
if err != nil {
panic(err)
}
}()

out, err := runApp(
&Flags{LogFile: "/dev/null", UseStorage: true, StoragePath: "/tmp/badger-test"},
&Flags{LogFile: "/dev/null", UseStorage: true, StoragePath: storagePath},
[]string{"test_dir"},
false,
testdev.DevicesInfoGetterMock{},
Expand All @@ -80,15 +81,16 @@ func TestReadFromStorage(t *testing.T) {
fin := testdir.CreateTestDir()
defer fin()

storagePath := "/tmp/badger-test4"
defer func() {
err := os.RemoveAll("/tmp/badger-test")
err := os.RemoveAll(storagePath)
if err != nil {
panic(err)
}
}()

out, err := runApp(
&Flags{LogFile: "/dev/null", UseStorage: true, StoragePath: "/tmp/badger-test"},
&Flags{LogFile: "/dev/null", UseStorage: true, StoragePath: storagePath},
[]string{"test_dir"},
false,
testdev.DevicesInfoGetterMock{},
Expand All @@ -97,7 +99,7 @@ func TestReadFromStorage(t *testing.T) {
assert.Nil(t, err)

out, err = runApp(
&Flags{LogFile: "/dev/null", ReadFromStorage: true, StoragePath: "/tmp/badger-test"},
&Flags{LogFile: "/dev/null", ReadFromStorage: true, StoragePath: storagePath},
[]string{"test_dir"},
false,
testdev.DevicesInfoGetterMock{},
Expand All @@ -111,7 +113,7 @@ func TestReadFromStorageWithErr(t *testing.T) {
defer fin()

_, err := runApp(
&Flags{LogFile: "/dev/null", ReadFromStorage: true, StoragePath: "/tmp/badger-test"},
&Flags{LogFile: "/dev/null", ReadFromStorage: true, StoragePath: "/tmp/badger-xxx"},
[]string{"test_dir"},
false,
testdev.DevicesInfoGetterMock{},
Expand Down
4 changes: 2 additions & 2 deletions report/export_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestReadFromStorage(t *testing.T) {
fin := testdir.CreateTestDir()
defer fin()

const storagePath = "/tmp/badger-test"
const storagePath = "/tmp/badger-test2"
defer func() {
err := os.RemoveAll(storagePath)
if err != nil {
Expand All @@ -43,7 +43,7 @@ func TestReadFromStorageWithErr(t *testing.T) {
fin := testdir.CreateTestDir()
defer fin()

const storagePath = "/tmp/badger-test"
const storagePath = "/tmp/badger-test3"

output := bytes.NewBuffer(make([]byte, 10))
reportOutput := bytes.NewBuffer(make([]byte, 10))
Expand Down

0 comments on commit 79642ad

Please sign in to comment.