Files
threshold/internal/daemon/controller/handlers/targets/testing.go
T
Johan Brandhorst-Satzkorn f89515a19c all: avoid mutating global state in parallel tests (#3687)
The SetupSuiteTargetFilters globally mutates the function used for logic
inside the target handler service. This means that we could get
inconsistent logical behavior in certain tests that were run in parallel,
since the logic can change at runtime. Ensure tests that make use
of this function are never run in parallel with other tests.
2023-09-07 11:52:00 -07:00

20 lines
510 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package targets
import (
"testing"
)
// SetupSuiteTargetFilters is used to ensure that OSS tests run from the ENT repo use the OSS level of target filtering
// WARNING: Do NOT run tests in parallel when using this.
func SetupSuiteTargetFilters(t *testing.T) {
oldFn := AuthorizeSessionWorkerFilterFn
AuthorizeSessionWorkerFilterFn = AuthorizeSessionWithWorkerFilter
t.Cleanup(func() {
AuthorizeSessionWorkerFilterFn = oldFn
})
}