mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
Some checks failed
build / Determine intended Terraform version (push) Has been cancelled
build / Determine Go toolchain version (push) Has been cancelled
Quick Checks / Unit Tests (push) Has been cancelled
Quick Checks / Race Tests (push) Has been cancelled
Quick Checks / End-to-end Tests (push) Has been cancelled
Quick Checks / Code Consistency Checks (push) Has been cancelled
Quick Checks / Automated defect checks (push) Has been cancelled
build / Generate release metadata (push) Has been cancelled
build / Build for freebsd_386 (push) Has been cancelled
build / Build for linux_386 (push) Has been cancelled
build / Build for openbsd_386 (push) Has been cancelled
build / Build for windows_386 (push) Has been cancelled
build / Build for darwin_amd64 (push) Has been cancelled
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build for linux_s390x (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build Docker image for linux_s390x (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
61 lines
1.1 KiB
Go
61 lines
1.1 KiB
Go
// 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
|
|
}
|