/
githubmirror
/
terraform
Обзор
Документация
Войти
/
githubmirror
/
terraform
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/policy/callback/testing.go
61 строка
1 KB
Samsondeen
Add policy client and protocol plumbing (#38514)
21 май 2026, 14:25
Не верифицирован
21 май 2026, 14:25
42fe426
Код
Авторство
О чём код?
// Copyright IBM Corp. 2014, 2026 // SPDX-License-Identifier: BUSL-1.1 package callback import "sync" var _ Registry = (*MockRegistry)(nil) // MockRegistry implements Registry for testing purposes. type MockRegistry struct { mu sync.Mutex NextIDCalled bool NextIDValue uint32 RegisterCalled bool FunctionsStore map[uint32]Functions UnregisterCalled bool GetCalled bool } func (m *MockRegistry) Register(id uint32, fns Functions) { m.mu.Lock() defer m.mu.Unlock() m.RegisterCalled = true if m.FunctionsStore == nil { m.FunctionsStore = make(map[uint32]Functions) } m.FunctionsStore[id] = fns } func (m *MockRegistry) Unregister(id uint32) { m.mu.Lock() defer m.mu.Unlock() m.UnregisterCalled = true if m.FunctionsStore != nil { delete(m.FunctionsStore, id) } } func (m *MockRegistry) Get(id uint32) (Functions, bool) { m.mu.Lock() defer m.mu.Unlock() m.GetCalled = true if m.FunctionsStore == nil { return Functions{}, false } fns, ok := m.FunctionsStore[id] return fns, ok } func (m *MockRegistry) NextID() uint32 { m.mu.Lock() defer m.mu.Unlock() m.NextIDCalled = true m.NextIDValue++ return m.NextIDValue }