Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing unit test for functions in dynamicconfig/config.go #5885

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions common/dynamicconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ func (s *configSuite) TestGetIntPropertyFilteredByDomain() {
s.Equal(50, value(domain))
}

func (s *configSuite) TestGetIntPropertyFilteredByWorkflowType() {
key := TestGetIntPropertyFilteredByWorkflowTypeKey
domain := "testDomain"
workflowType := "testWorkflowType"
value := s.cln.GetIntPropertyFilteredByWorkflowType(key)
s.Equal(key.DefaultInt(), value(domain, workflowType))
s.client.SetValue(key, 50)
s.Equal(50, value(domain, workflowType))
}

func (s *configSuite) TestGetIntPropertyFilteredByShardID() {
key := TestGetIntPropertyFilteredByShardIDKey
shardID := 1
value := s.cln.GetIntPropertyFilteredByShardID(key)
s.Equal(key.DefaultInt(), value(shardID))
s.client.SetValue(key, 10)
s.Equal(10, value(shardID))
}

func (s *configSuite) TestGetStringPropertyFnWithDomainFilter() {
key := DefaultEventEncoding
domain := "testDomain"
Expand Down Expand Up @@ -100,6 +119,15 @@ func (s *configSuite) TestGetFloat64Property() {
s.Equal(0.01, value())
}

func (s *configSuite) TestGetFloat64PropertyFilteredByShardID() {
key := TestGetFloat64PropertyFilteredByShardIDKey
shardID := 1
value := s.cln.GetFloat64PropertyFilteredByShardID(key)
s.Equal(key.DefaultFloat(), value(shardID))
s.client.SetValue(key, 0.01)
s.Equal(0.01, value(shardID))
}

func (s *configSuite) TestGetBoolProperty() {
key := TestGetBoolPropertyKey
value := s.cln.GetBoolProperty(key)
Expand All @@ -117,6 +145,25 @@ func (s *configSuite) TestGetBoolPropertyFilteredByDomainID() {
s.Equal(false, value(domainID))
}

func (s *configSuite) TestGetBoolPropertyFilteredByDomain() {
key := TestGetBoolPropertyFilteredByDomainKey
domain := "testDomain"
value := s.cln.GetBoolPropertyFilteredByDomain(key)
s.Equal(key.DefaultBool(), value(domain))
s.client.SetValue(key, true)
s.Equal(true, value(domain))
}

func (s *configSuite) TestGetBoolPropertyFilteredByDomainIDAndWorkflowID() {
key := TestGetBoolPropertyFilteredByDomainIDAndWorkflowIDKey
domainID := "testDomainID"
workflowID := "testWorkflowID"
value := s.cln.GetBoolPropertyFilteredByDomainIDAndWorkflowID(key)
s.Equal(key.DefaultBool(), value(domainID, workflowID))
s.client.SetValue(key, true)
s.Equal(true, value(domainID, workflowID))
}

func (s *configSuite) TestGetBoolPropertyFilteredByTaskListInfo() {
key := TestGetBoolPropertyFilteredByTaskListInfoKey
domain := "testDomain"
Expand Down Expand Up @@ -145,6 +192,24 @@ func (s *configSuite) TestGetDurationPropertyFilteredByDomain() {
s.Equal(time.Minute, value(domain))
}

func (s *configSuite) TestGetDurationPropertyFilteredByDomainID() {
key := TestGetDurationPropertyFilteredByDomainIDKey
domain := "testDomainID"
value := s.cln.GetDurationPropertyFilteredByDomainID(key)
s.Equal(key.DefaultDuration(), value(domain))
s.client.SetValue(key, time.Minute)
s.Equal(time.Minute, value(domain))
}

func (s *configSuite) TestGetDurationPropertyFilteredByShardID() {
key := TestGetDurationPropertyFilteredByShardID
shardID := 1
value := s.cln.GetDurationPropertyFilteredByShardID(key)
s.Equal(key.DefaultDuration(), value(shardID))
s.client.SetValue(key, time.Minute)
s.Equal(time.Minute, value(shardID))
}

func (s *configSuite) TestGetDurationPropertyFilteredByTaskListInfo() {
key := TestGetDurationPropertyFilteredByTaskListInfoKey
domain := "testDomain"
Expand All @@ -156,6 +221,16 @@ func (s *configSuite) TestGetDurationPropertyFilteredByTaskListInfo() {
s.Equal(time.Minute, value(domain, taskList, taskType))
}

func (s *configSuite) TestGetDurationPropertyFilteredByWorkflowType() {
key := TestGetDurationPropertyFilteredByWorkflowTypeKey
domain := "testDomain"
workflowType := "testWorkflowType"
value := s.cln.GetDurationPropertyFilteredByWorkflowType(key)
s.Equal(key.DefaultDuration(), value(domain, workflowType))
s.client.SetValue(key, time.Minute)
s.Equal(time.Minute, value(domain, workflowType))
}

func (s *configSuite) TestGetMapProperty() {
key := TestGetMapPropertyKey
val := map[string]interface{}{
Expand All @@ -169,6 +244,17 @@ func (s *configSuite) TestGetMapProperty() {
s.Equal("321", value()["testKey"])
}

func (s *configSuite) TestGetListProperty() {
key := TestGetListPropertyKey
arr := []interface{}{}
value := s.cln.GetListProperty(key)
s.Equal(key.DefaultList(), value())
arr = append(arr, 1)
s.client.SetValue(key, arr)
s.Equal(1, len(value()))
s.Equal(1, value()[0])
}

func (s *configSuite) TestUpdateConfig() {
key := TestGetBoolPropertyKey
value := s.cln.GetBoolProperty(key)
Expand Down
Loading
Loading