Skip to content

Commit

Permalink
Add test to ensure dynamic config key has mapped value (#922)
Browse files Browse the repository at this point in the history
* Add test for ensure dynamic config key has mapped value

* Add test for filter
  • Loading branch information
vancexu authored Jul 3, 2018
1 parent a9a3727 commit 57e8196
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
16 changes: 16 additions & 0 deletions common/service/dynamicconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/uber-common/bark"
)
Expand Down Expand Up @@ -219,3 +220,18 @@ func (s *configSuite) TestGetDurationPropertyFilteredByTaskListInfo() {
s.client.SetValue(key, time.Minute)
s.Equal(time.Minute, value(domain, taskList, taskType))
}

func TestDynamicConfigKeyIsMapped(t *testing.T) {
for i := unknownKey; i < lastKeyForTest; i++ {
key, ok := keys[i]
require.True(t, ok)
require.NotEmpty(t, key)
}
}

func TestDynamicConfigFilterTypeIsMapped(t *testing.T) {
require.Equal(t, int(lastFilterTypeForTest), len(filters))
for i := unknownFilter; i < lastFilterTypeForTest; i++ {
require.NotEmpty(t, filters[i])
}
}
23 changes: 16 additions & 7 deletions common/service/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ var keys = map[Key]string{
unknownKey: "unknownKey",

// tests keys
testGetPropertyKey: "testGetPropertyKey",
testGetIntPropertyKey: "testGetIntPropertyKey",
testGetFloat64PropertyKey: "testGetFloat64PropertyKey",
testGetDurationPropertyKey: "testGetDurationPropertyKey",
testGetBoolPropertyKey: "testGetBoolPropertyKey",
testGetIntPropertyFilteredByDomainKey: "testGetIntPropertyFilteredByDomainKey",
testGetDurationPropertyFilteredByDomainKey: "testGetDurationPropertyFilteredByDomainKey",
testGetPropertyKey: "testGetPropertyKey",
testGetIntPropertyKey: "testGetIntPropertyKey",
testGetFloat64PropertyKey: "testGetFloat64PropertyKey",
testGetDurationPropertyKey: "testGetDurationPropertyKey",
testGetBoolPropertyKey: "testGetBoolPropertyKey",
testGetIntPropertyFilteredByDomainKey: "testGetIntPropertyFilteredByDomainKey",
testGetDurationPropertyFilteredByDomainKey: "testGetDurationPropertyFilteredByDomainKey",
testGetIntPropertyFilteredByTaskListInfoKey: "testGetIntPropertyFilteredByTaskListInfoKey",
testGetDurationPropertyFilteredByTaskListInfoKey: "testGetDurationPropertyFilteredByTaskListInfoKey",
testGetBoolPropertyFilteredByTaskListInfoKey: "testGetBoolPropertyFilteredByTaskListInfoKey",

// system settings
EnableGlobalDomain: "system.enableGlobalDomain",
Expand Down Expand Up @@ -239,6 +242,9 @@ const (
MaximumBufferedEventsBatch
// ShardUpdateMinInterval is the minimal time interval which the shard info can be updated
ShardUpdateMinInterval

// lastKeyForTest must be the last one in this const group for testing purpose
lastKeyForTest
)

// Filter represents a filter on the dynamic config key
Expand Down Expand Up @@ -266,6 +272,9 @@ const (
TaskListName
// TaskType is the task type (0:Decision, 1:Activity)
TaskType

// lastFilterTypeForTest must be the last one in this const group for testing purpose
lastFilterTypeForTest
)

// FilterOption is used to provide filters for dynamic config keys
Expand Down

0 comments on commit 57e8196

Please sign in to comment.