2015-04-01 16:34:32 +00:00
|
|
|
package system
|
|
|
|
|
2015-12-04 22:09:07 +00:00
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/mock"
|
2015-04-06 16:32:10 +00:00
|
|
|
|
2015-12-04 22:09:07 +00:00
|
|
|
"github.com/shirou/gopsutil/cpu"
|
|
|
|
"github.com/shirou/gopsutil/disk"
|
2015-04-06 23:03:09 +00:00
|
|
|
|
2015-12-04 22:09:07 +00:00
|
|
|
"github.com/shirou/gopsutil/load"
|
|
|
|
"github.com/shirou/gopsutil/mem"
|
|
|
|
"github.com/shirou/gopsutil/net"
|
|
|
|
)
|
2015-04-01 16:34:32 +00:00
|
|
|
|
|
|
|
type MockPS struct {
|
|
|
|
mock.Mock
|
|
|
|
}
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
func (m *MockPS) LoadAvg() (*load.AvgStat, error) {
|
2015-04-01 16:34:32 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).(*load.AvgStat)
|
2015-04-01 16:34:32 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
func (m *MockPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error) {
|
2015-04-06 16:32:10 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).([]cpu.TimesStat)
|
2015-04-06 16:32:10 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2016-12-05 17:42:36 +00:00
|
|
|
func (m *MockPS) DiskUsage(mountPointFilter []string, fstypeExclude []string) ([]*disk.UsageStat, []*disk.PartitionStat, error) {
|
2016-02-22 17:29:10 +00:00
|
|
|
ret := m.Called(mountPointFilter, fstypeExclude)
|
2015-04-06 17:34:55 +00:00
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).([]*disk.UsageStat)
|
2016-12-05 17:42:36 +00:00
|
|
|
r1 := ret.Get(1).([]*disk.PartitionStat)
|
|
|
|
r2 := ret.Error(2)
|
2015-04-06 17:34:55 +00:00
|
|
|
|
2016-12-05 17:42:36 +00:00
|
|
|
return r0, r1, r2
|
2015-04-06 17:34:55 +00:00
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
func (m *MockPS) NetIO() ([]net.IOCountersStat, error) {
|
2015-04-06 17:44:32 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).([]net.IOCountersStat)
|
2015-04-06 17:44:32 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
func (m *MockPS) NetProto() ([]net.ProtoCountersStat, error) {
|
2015-12-04 22:09:07 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).([]net.ProtoCountersStat)
|
2015-12-04 22:09:07 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:41:09 +00:00
|
|
|
func (m *MockPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error) {
|
2015-04-06 17:59:05 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).(map[string]disk.IOCountersStat)
|
2015-04-06 17:59:05 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2015-04-06 21:53:43 +00:00
|
|
|
func (m *MockPS) VMStat() (*mem.VirtualMemoryStat, error) {
|
|
|
|
ret := m.Called()
|
|
|
|
|
|
|
|
r0 := ret.Get(0).(*mem.VirtualMemoryStat)
|
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2015-04-06 21:53:43 +00:00
|
|
|
func (m *MockPS) SwapStat() (*mem.SwapMemoryStat, error) {
|
|
|
|
ret := m.Called()
|
|
|
|
|
|
|
|
r0 := ret.Get(0).(*mem.SwapMemoryStat)
|
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|
2015-12-04 22:09:07 +00:00
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
func (m *MockPS) NetConnections() ([]net.ConnectionStat, error) {
|
2015-10-08 13:55:34 +00:00
|
|
|
ret := m.Called()
|
|
|
|
|
2016-05-19 14:05:08 +00:00
|
|
|
r0 := ret.Get(0).([]net.ConnectionStat)
|
2015-10-08 13:55:34 +00:00
|
|
|
r1 := ret.Error(1)
|
|
|
|
|
|
|
|
return r0, r1
|
|
|
|
}
|