(t *testing.T)
| 747 | } |
| 748 | |
| 749 | func Test_resolveConflicts(t *testing.T) { |
| 750 | tests := []struct { |
| 751 | name string |
| 752 | args map[string]InstanceDesc |
| 753 | want map[string]InstanceDesc |
| 754 | }{ |
| 755 | { |
| 756 | name: "Empty input", |
| 757 | args: map[string]InstanceDesc{}, |
| 758 | want: map[string]InstanceDesc{}, |
| 759 | }, |
| 760 | { |
| 761 | name: "No conflicts", |
| 762 | args: map[string]InstanceDesc{ |
| 763 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 764 | "ing2": {State: ACTIVE, Tokens: []uint32{4, 5, 6}}, |
| 765 | }, |
| 766 | want: map[string]InstanceDesc{ |
| 767 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 768 | "ing2": {State: ACTIVE, Tokens: []uint32{4, 5, 6}}, |
| 769 | }, |
| 770 | }, |
| 771 | { |
| 772 | name: "Conflict resolution with LEFT state", |
| 773 | args: map[string]InstanceDesc{ |
| 774 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 775 | "ing2": {State: LEFT, Tokens: []uint32{1, 2, 3, 4}}, |
| 776 | }, |
| 777 | want: map[string]InstanceDesc{ |
| 778 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 779 | "ing2": {State: LEFT, Tokens: nil}, |
| 780 | }, |
| 781 | }, |
| 782 | { |
| 783 | name: "Conflict resolution with LEAVING state", |
| 784 | args: map[string]InstanceDesc{ |
| 785 | "ing1": {State: LEAVING, Tokens: []uint32{1, 2, 3}}, |
| 786 | "ing2": {State: PENDING, Tokens: []uint32{1, 2, 3, 4}}, |
| 787 | }, |
| 788 | want: map[string]InstanceDesc{ |
| 789 | "ing1": {State: LEAVING, Tokens: nil}, |
| 790 | "ing2": {State: PENDING, Tokens: []uint32{1, 2, 3, 4}}, |
| 791 | }, |
| 792 | }, |
| 793 | { |
| 794 | name: "Conflict resolution with JOINING state", |
| 795 | args: map[string]InstanceDesc{ |
| 796 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 797 | "ing2": {State: JOINING, Tokens: []uint32{1, 2, 3, 4}}, |
| 798 | }, |
| 799 | want: map[string]InstanceDesc{ |
| 800 | "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}}, |
| 801 | "ing2": {State: JOINING, Tokens: []uint32{4}}, |
| 802 | }, |
| 803 | }, |
| 804 | { |
| 805 | name: "Conflict resolution with same state", |
| 806 | args: map[string]InstanceDesc{ |
nothing calls this directly
no test coverage detected