/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/fs/duf/groups_test.go
46 строк
1 KB
Michael Mayer
FS: Add /pkg/fs/duf to determine mount points and disk usage #4266
03 мар 2025, 13:24
03 мар 2025, 13:24
e1a9a68
Код
Авторство
О чём код?
package duf import ( "testing" "github.com/stretchr/testify/assert" ) func TestGroupMounts(t *testing.T) { t.Run("Success", func(t *testing.T) { // Get slice of mounted file systems. m, warnings, err := Mounts() // No warnings or errors are expected. assert.NoError(t, err) assert.Empty(t, warnings) filters := FilterOptions{ HiddenDevices: parseCommaSeparatedValues(hideDevices), OnlyDevices: parseCommaSeparatedValues(onlyDevices), HiddenFilesystems: parseCommaSeparatedValues(hideFs), OnlyFilesystems: parseCommaSeparatedValues(onlyFs), HiddenMountPoints: parseCommaSeparatedValues(hideMp), OnlyMountPoints: parseCommaSeparatedValues(onlyMp), } results := GroupMounts(m, filters) t.Logf("results, %#v", results) // At least one mount returned? if len(results) < 1 { t.Error("at least one result expected") } else if local, found := results[LocalDevice]; found { for _, d := range local { if d.Total <= 0 { t.Error("total should be a positive integer") } else { t.Logf("%s is mounted at %s: %d of %d GB used (%.1f%%)", d.Device, d.Mountpoint, d.Used/GB, d.Total/GB, (float64(d.Used)/float64(d.Total))*100) } } } else { t.Error("no local devices found") } }) }