github.com/schwarzm/garden-linux@v0.0.0-20150507151835-33bca2147c47/old/bandwidth_manager/fake_bandwidth_manager/fake_bandwidth_manager.go (about)

     1  package fake_bandwidth_manager
     2  
     3  import (
     4  	"github.com/cloudfoundry-incubator/garden"
     5  	"github.com/pivotal-golang/lager"
     6  )
     7  
     8  type FakeBandwidthManager struct {
     9  	SetLimitsError error
    10  	EnforcedLimits []garden.BandwidthLimits
    11  
    12  	GetLimitsError  error
    13  	GetLimitsResult garden.ContainerBandwidthStat
    14  }
    15  
    16  func New() *FakeBandwidthManager {
    17  	return &FakeBandwidthManager{}
    18  }
    19  
    20  func (m *FakeBandwidthManager) SetLimits(logger lager.Logger, limits garden.BandwidthLimits) error {
    21  	if m.SetLimitsError != nil {
    22  		return m.SetLimitsError
    23  	}
    24  
    25  	m.EnforcedLimits = append(m.EnforcedLimits, limits)
    26  
    27  	return nil
    28  }
    29  
    30  func (m *FakeBandwidthManager) GetLimits(logger lager.Logger) (garden.ContainerBandwidthStat, error) {
    31  	if m.GetLimitsError != nil {
    32  		return garden.ContainerBandwidthStat{}, m.GetLimitsError
    33  	}
    34  
    35  	return m.GetLimitsResult, nil
    36  }