← back to keneo__docker-dynamic-limits

Function bodies 128 total

All specs Real LLM only Function bodies
testutil.MockDocker.PauseContainer method · go · L231-L240 (10 LOC)
internal/testutil/mocks.go
func (d *MockDocker) PauseContainer(ctx context.Context, id string) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return fmt.Errorf("container %s not found", id)
	}
	state.Paused = true
	return nil
}
testutil.MockDocker.UnpauseContainer method · go · L242-L251 (10 LOC)
internal/testutil/mocks.go
func (d *MockDocker) UnpauseContainer(ctx context.Context, id string) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return fmt.Errorf("container %s not found", id)
	}
	state.Paused = false
	return nil
}
testutil.MockDocker.IsContainerPaused method · go · L253-L261 (9 LOC)
internal/testutil/mocks.go
func (d *MockDocker) IsContainerPaused(ctx context.Context, id string) (bool, error) {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return false, fmt.Errorf("container %s not found", id)
	}
	return state.Paused, nil
}
testutil.MockDocker.IsContainerRunning method · go · L263-L271 (9 LOC)
internal/testutil/mocks.go
func (d *MockDocker) IsContainerRunning(ctx context.Context, id string) (bool, error) {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return false, fmt.Errorf("container %s not found", id)
	}
	return state.Running, nil
}
testutil.MockDocker.UpdateMemoryLimit method · go · L273-L282 (10 LOC)
internal/testutil/mocks.go
func (d *MockDocker) UpdateMemoryLimit(ctx context.Context, id string, memoryBytes int64) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return fmt.Errorf("container %s not found", id)
	}
	state.MemoryLimit = memoryBytes
	return nil
}
testutil.MockDocker.CloneContainer method · go · L288-L306 (19 LOC)
internal/testutil/mocks.go
func (d *MockDocker) CloneContainer(ctx context.Context, sourceID string, newName string) (string, error) {
	d.mu.Lock()
	defer d.mu.Unlock()
	if _, ok := d.Containers[sourceID]; !ok {
		return "", fmt.Errorf("container %s not found", sourceID)
	}
	d.ClonedFrom = append(d.ClonedFrom, sourceID)
	d.CloneIDCounter++
	newID := fmt.Sprintf("clone%06d%06d", d.CloneIDCounter, 0)
	if newName == "" {
		newName = "clone"
	}
	d.Containers[newID] = &MockContainerState{
		Running:  true,
		Networks: []string{"bridge"},
		Name:     newName,
	}
	return newID, nil
}
testutil.MockDocker.GetContainerDiskUsage method · go · L308-L316 (9 LOC)
internal/testutil/mocks.go
func (d *MockDocker) GetContainerDiskUsage(ctx context.Context, id string) (int64, error) {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return 0, fmt.Errorf("container %s not found", id)
	}
	return state.DiskUsage, nil
}
Powered by Repobility — scan your code at https://repobility.com
testutil.MockDocker.DisconnectNetwork method · go · L318-L327 (10 LOC)
internal/testutil/mocks.go
func (d *MockDocker) DisconnectNetwork(ctx context.Context, id string) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return fmt.Errorf("container %s not found", id)
	}
	state.Networks = nil
	return nil
}
testutil.MockDocker.ReconnectNetwork method · go · L329-L338 (10 LOC)
internal/testutil/mocks.go
func (d *MockDocker) ReconnectNetwork(ctx context.Context, id string) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return fmt.Errorf("container %s not found", id)
	}
	state.Networks = []string{"bridge"}
	return nil
}
testutil.MockDocker.ContainerIP method · go · L340-L351 (12 LOC)
internal/testutil/mocks.go
func (d *MockDocker) ContainerIP(ctx context.Context, id string) (string, error) {
	d.mu.Lock()
	defer d.mu.Unlock()
	state, ok := d.Containers[id]
	if !ok {
		return "", fmt.Errorf("container %s not found", id)
	}
	if state.IP == "" {
		return "", fmt.Errorf("no IP address for container %s", id)
	}
	return state.IP, nil
}
testutil.MockDocker.SetContainerIP method · go · L353-L359 (7 LOC)
internal/testutil/mocks.go
func (d *MockDocker) SetContainerIP(id, ip string) {
	d.mu.Lock()
	defer d.mu.Unlock()
	if state, ok := d.Containers[id]; ok {
		state.IP = ip
	}
}
testutil.NewMockCgroup function · go · L375-L385 (11 LOC)
internal/testutil/mocks.go
func NewMockCgroup() *MockCgroup {
	return &MockCgroup{
		CgroupPaths: make(map[string]string),
		CPUUsage:    make(map[string]int64),
		MemCurrent:  make(map[string]int64),
		MemMax:      make(map[string]int64),
		IOStats:     make(map[string]*cgroup.IOStats),
		IOMax:       make(map[string]string),
		NetStats:    make(map[string]*cgroup.NetworkStats),
	}
}
testutil.MockCgroup.FindCgroupPath method · go · L387-L395 (9 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) FindCgroupPath(dockerID string) (string, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	p, ok := c.CgroupPaths[dockerID]
	if !ok {
		return "", fmt.Errorf("cgroup path not found for container %s", dockerID)
	}
	return p, nil
}
testutil.MockCgroup.CPUUsageMicroseconds method · go · L397-L405 (9 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) CPUUsageMicroseconds(cgroupPath string) (int64, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	v, ok := c.CPUUsage[cgroupPath]
	if !ok {
		return 0, fmt.Errorf("cpu.stat not found")
	}
	return v, nil
}
testutil.MockCgroup.MemoryCurrent method · go · L407-L415 (9 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) MemoryCurrent(cgroupPath string) (int64, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	v, ok := c.MemCurrent[cgroupPath]
	if !ok {
		return 0, fmt.Errorf("memory.current not found")
	}
	return v, nil
}
Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
testutil.MockCgroup.SetMemoryMax method · go · L417-L422 (6 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) SetMemoryMax(cgroupPath string, bytes int64) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	c.MemMax[cgroupPath] = bytes
	return nil
}
testutil.MockCgroup.ReadIOStat method · go · L424-L432 (9 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) ReadIOStat(cgroupPath string) (*cgroup.IOStats, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	s, ok := c.IOStats[cgroupPath]
	if !ok {
		return &cgroup.IOStats{}, nil
	}
	return s, nil
}
testutil.MockCgroup.SetIOMax method · go · L434-L439 (6 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) SetIOMax(cgroupPath string, deviceNum string, bps int64, iops int64) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	c.IOMax[cgroupPath] = fmt.Sprintf("%s rbps=%d wbps=%d riops=%d wiops=%d", deviceNum, bps, bps, iops, iops)
	return nil
}
testutil.MockCgroup.RemoveIOMax method · go · L441-L446 (6 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) RemoveIOMax(cgroupPath string, deviceNum string) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	delete(c.IOMax, cgroupPath)
	return nil
}
testutil.MockCgroup.ReadNetworkStats method · go · L448-L456 (9 LOC)
internal/testutil/mocks.go
func (c *MockCgroup) ReadNetworkStats(vethName string) (*cgroup.NetworkStats, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	s, ok := c.NetStats[vethName]
	if !ok {
		return &cgroup.NetworkStats{}, nil
	}
	return s, nil
}
testutil.NewMockEnforcement function · go · L469-L474 (6 LOC)
internal/testutil/mocks.go
func NewMockEnforcement() *MockEnforcement {
	return &MockEnforcement{
		Started:  make(map[string]string),
		Enforced: make(map[string]map[model.LimitType]bool),
	}
}
testutil.MockEnforcement.StopContainer method · go · L482-L487 (6 LOC)
internal/testutil/mocks.go
func (e *MockEnforcement) StopContainer(containerID string) {
	e.mu.Lock()
	defer e.mu.Unlock()
	e.Stopped = append(e.Stopped, containerID)
	delete(e.Started, containerID)
}
testutil.MockEnforcement.IsEnforced method · go · L489-L496 (8 LOC)
internal/testutil/mocks.go
func (e *MockEnforcement) IsEnforced(containerID string, lt model.LimitType) bool {
	e.mu.Lock()
	defer e.mu.Unlock()
	if m, ok := e.Enforced[containerID]; ok {
		return m[lt]
	}
	return false
}
Same scanner, your repo: https://repobility.com — Repobility
testutil.MockEnforcement.GetEnforced method · go · L498-L508 (11 LOC)
internal/testutil/mocks.go
func (e *MockEnforcement) GetEnforced(containerID string) map[model.LimitType]bool {
	e.mu.Lock()
	defer e.mu.Unlock()
	result := make(map[model.LimitType]bool)
	if m, ok := e.Enforced[containerID]; ok {
		for k, v := range m {
			result[k] = v
		}
	}
	return result
}
testutil.MockEnforcement.WasStarted method · go · L517-L522 (6 LOC)
internal/testutil/mocks.go
func (e *MockEnforcement) WasStarted(containerID string) bool {
	e.mu.Lock()
	defer e.mu.Unlock()
	_, ok := e.Started[containerID]
	return ok
}
testutil.MockEnforcement.WasStopped method · go · L525-L534 (10 LOC)
internal/testutil/mocks.go
func (e *MockEnforcement) WasStopped(containerID string) bool {
	e.mu.Lock()
	defer e.mu.Unlock()
	for _, id := range e.Stopped {
		if id == containerID {
			return true
		}
	}
	return false
}
testutil.NewMockProxy function · go · L553-L559 (7 LOC)
internal/testutil/mocks.go
func NewMockProxy() *MockProxy {
	return &MockProxy{
		Spending: make(map[string]int64),
		Budgets:  make(map[string]int64),
		Addrs:    make(map[string]string),
	}
}
testutil.MockProxy.RegisterContainer method · go · L561-L569 (9 LOC)
internal/testutil/mocks.go
func (p *MockProxy) RegisterContainer(containerID string, budget int64, existingSpending int64) (string, error) {
	p.mu.Lock()
	defer p.mu.Unlock()
	addr := fmt.Sprintf("127.0.0.1:%d", 10000+len(p.Addrs))
	p.Addrs[containerID] = addr
	p.Spending[containerID] = existingSpending
	p.Budgets[containerID] = budget
	return addr, nil
}
‹ prevpage 3 / 3