Simplify system.DiskUsage() (#2630)

This commit is contained in:
Nikolay Denev
2017-04-18 19:42:58 +01:00
committed by Daniel Nelson
parent 70b3e763e7
commit eb7ef5392e
8 changed files with 212 additions and 28 deletions

View File

@@ -1,6 +1,8 @@
package system
import (
"os"
"github.com/stretchr/testify/mock"
"github.com/shirou/gopsutil/cpu"
@@ -13,6 +15,16 @@ import (
type MockPS struct {
mock.Mock
PSDiskDeps
}
type MockPSDisk struct {
*systemPS
*mock.Mock
}
type mockDiskUsage struct {
*mock.Mock
}
func (m *MockPS) LoadAvg() (*load.AvgStat, error) {
@@ -96,3 +108,35 @@ func (m *MockPS) NetConnections() ([]net.ConnectionStat, error) {
return r0, r1
}
func (m *mockDiskUsage) Partitions(all bool) ([]disk.PartitionStat, error) {
ret := m.Called(all)
r0 := ret.Get(0).([]disk.PartitionStat)
r1 := ret.Error(1)
return r0, r1
}
func (m *mockDiskUsage) OSGetenv(key string) string {
ret := m.Called(key)
return ret.Get(0).(string)
}
func (m *mockDiskUsage) OSStat(name string) (os.FileInfo, error) {
ret := m.Called(name)
r0 := ret.Get(0).(os.FileInfo)
r1 := ret.Error(1)
return r0, r1
}
func (m *mockDiskUsage) PSDiskUsage(path string) (*disk.UsageStat, error) {
ret := m.Called(path)
r0 := ret.Get(0).(*disk.UsageStat)
r1 := ret.Error(1)
return r0, r1
}