Skip to content

Commit

Permalink
add unit tests for WorkflowIDToHistoryShard and DomainIDToHistoryShard (
Browse files Browse the repository at this point in the history
  • Loading branch information
arzonus authored Dec 22, 2023
1 parent 823e0bb commit 0d5ad36
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions common/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,53 @@ func TestConvertGetTaskFailedCauseToErr(t *testing.T) {
})
}
}

func TestWorkflowIDToHistoryShard(t *testing.T) {
for _, c := range []struct {
workflowID string
numberOfShards int

want int
}{
{
workflowID: "",
numberOfShards: 1000,
want: 242,
},
{
workflowID: "workflowId",
numberOfShards: 1000,
want: 580,
},
} {
t.Run(fmt.Sprintf("%s-%v", c.workflowID, c.numberOfShards), func(t *testing.T) {
got := WorkflowIDToHistoryShard(c.workflowID, c.numberOfShards)
require.Equal(t, c.want, got)
})
}
}

func TestDomainIDToHistoryShard(t *testing.T) {
for _, c := range []struct {
domainID string
numberOfShards int

want int
}{
{
domainID: "",
numberOfShards: 1000,
want: 242,
},
{
domainID: "domainId",
numberOfShards: 1000,
want: 600,
},
} {
t.Run(fmt.Sprintf("%s-%v", c.domainID, c.numberOfShards), func(t *testing.T) {
got := DomainIDToHistoryShard(c.domainID, c.numberOfShards)
require.Equal(t, c.want, got)
})
}
}

0 comments on commit 0d5ad36

Please sign in to comment.