mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Added a guard for detecting if `WithDedicatedCluster` option for `TestEnv` was unnecessary. ## Why? Using a dedicated cluster when not needed is wasteful. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package testcore
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
|
|
"go.temporal.io/server/common/testing/parallelsuite"
|
|
)
|
|
|
|
type TestEnvSuite struct {
|
|
parallelsuite.Suite[*TestEnvSuite]
|
|
}
|
|
|
|
func TestTestEnvSuite(t *testing.T) {
|
|
parallelsuite.Run(t, &TestEnvSuite{})
|
|
}
|
|
|
|
func (s *TestEnvSuite) TestDedicatedClusterGuard_NoErrorWithoutExplicitRequest() {
|
|
guard := newDedicatedClusterGuard(false)
|
|
|
|
s.NoError(guard.validate())
|
|
}
|
|
|
|
func (s *TestEnvSuite) TestDedicatedClusterGuard_FailsWhenUnused() {
|
|
guard := newDedicatedClusterGuard(true)
|
|
|
|
s.EqualError(guard.validate(),
|
|
`testcore.WithDedicatedCluster() was requested but no dedicated-cluster-only feature was used`)
|
|
}
|
|
|
|
func (s *TestEnvSuite) TestDedicatedClusterGuard_NoErrorAfterUse() {
|
|
guard := newDedicatedClusterGuard(true)
|
|
guard.record("global hook")
|
|
|
|
s.NoError(guard.validate())
|
|
}
|
|
|
|
func (s *TestEnvSuite) TestDedicatedClusterGuard_ConcurrentRecord() {
|
|
guard := newDedicatedClusterGuard(true)
|
|
var wg sync.WaitGroup
|
|
for range 10 {
|
|
wg.Go(func() {
|
|
guard.record("reason")
|
|
})
|
|
}
|
|
wg.Wait()
|
|
s.NoError(guard.validate())
|
|
}
|