mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
package dynamicconfig_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"go.temporal.io/server/common/dynamicconfig"
|
|
)
|
|
|
|
func TestMemoryClient(t *testing.T) {
|
|
c := dynamicconfig.NewMemoryClient()
|
|
k := dynamicconfig.Key("key")
|
|
|
|
// plain override
|
|
assert.Nil(t, c.GetValue(k))
|
|
remove := c.OverrideValue(k, 123)
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 123}}, c.GetValue(k))
|
|
remove()
|
|
assert.Nil(t, c.GetValue(k))
|
|
|
|
// two levels, pop in correct order
|
|
remove1 := c.OverrideValue(k, 123)
|
|
remove2 := c.OverrideValue(k, 456)
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 456}}, c.GetValue(k))
|
|
remove2()
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 123}}, c.GetValue(k))
|
|
remove1()
|
|
assert.Nil(t, c.GetValue(k))
|
|
|
|
// three levels, pop in wrong order
|
|
remove1 = c.OverrideValue(k, 123)
|
|
remove2 = c.OverrideValue(k, 456)
|
|
remove3 := c.OverrideValue(k, 789)
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 789}}, c.GetValue(k))
|
|
remove2()
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 789}}, c.GetValue(k))
|
|
remove3()
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 123}}, c.GetValue(k))
|
|
remove1()
|
|
remove3() // no-op
|
|
remove2() // no-op
|
|
assert.Nil(t, c.GetValue(k))
|
|
}
|
|
|
|
func TestMemoryClientSubscriptions(t *testing.T) {
|
|
c := dynamicconfig.NewMemoryClient()
|
|
k := dynamicconfig.Key("key")
|
|
|
|
calls := 0
|
|
|
|
c.Subscribe(func(changed map[dynamicconfig.Key][]dynamicconfig.ConstrainedValue) {
|
|
calls++
|
|
assert.Contains(t, changed, k)
|
|
switch calls {
|
|
case 1:
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 123}}, changed[k])
|
|
case 2:
|
|
assert.Nil(t, changed[k])
|
|
case 3:
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 456}}, changed[k])
|
|
case 4:
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 789}}, changed[k])
|
|
case 5:
|
|
assert.Equal(t, []dynamicconfig.ConstrainedValue{{Value: 456}}, changed[k])
|
|
case 6:
|
|
assert.Nil(t, changed[k])
|
|
}
|
|
})
|
|
|
|
remove := c.OverrideValue(k, 123)
|
|
assert.Equal(t, 1, calls)
|
|
remove()
|
|
assert.Equal(t, 2, calls)
|
|
|
|
remove1 := c.OverrideValue(k, 456)
|
|
assert.Equal(t, 3, calls)
|
|
remove2 := c.OverrideValue(k, 789)
|
|
assert.Equal(t, 4, calls)
|
|
remove2()
|
|
assert.Equal(t, 5, calls)
|
|
remove1()
|
|
assert.Equal(t, 6, calls)
|
|
}
|