Skip to content

Commit

Permalink
new file: assign_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
childe committed Mar 6, 2018
1 parent 3ba86b4 commit ed6ca6c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions assign_test.go
@@ -0,0 +1,39 @@
package healer

import "testing"

func TestAssgin(t *testing.T) {
var (
s = &RangeAssignmentStrategy{}
members []string
partitions []int32
rst map[string][]int32
)
members = []string{"1", "2"}
partitions = []int32{0, 1, 2, 3, 4}
rst = s.assignPartitions(members, partitions)

if len(rst) != 2 {
t.Error("rst length != 2")
}
if len(rst["1"]) != 3 {
t.Error("partitions in memeber 1 != 3")
}
if len(rst["2"]) != 2 {
t.Error("partitions in memeber 2 != 2")
}

members = []string{"1", "2"}
partitions = []int32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
rst = s.assignPartitions(members, partitions)

if len(rst) != 2 {
t.Error("rst length != 2")
}
if len(rst["1"]) != 5 {
t.Error("partitions in memeber 1 != 5")
}
if len(rst["2"]) != 5 {
t.Error("partitions in memeber 2 != 5")
}
}

0 comments on commit ed6ca6c

Please sign in to comment.