|
|
@ -72,12 +72,9 @@ func TestContainer(t *testing.T) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
act: actionDel,
|
|
|
|
act: actionDel,
|
|
|
|
key: "first",
|
|
|
|
key: "first",
|
|
|
|
val: "a",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expect: []string{
|
|
|
|
|
|
|
|
"b",
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
expect: []string{"b"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "add two, delete two",
|
|
|
|
name: "add two, delete two",
|
|
|
@ -95,21 +92,83 @@ func TestContainer(t *testing.T) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
act: actionDel,
|
|
|
|
act: actionDel,
|
|
|
|
key: "first",
|
|
|
|
key: "first",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionDel,
|
|
|
|
|
|
|
|
key: "second",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
expect: []string{},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "add three, dup values, delete two",
|
|
|
|
|
|
|
|
do: []action{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "first",
|
|
|
|
val: "a",
|
|
|
|
val: "a",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "second",
|
|
|
|
|
|
|
|
val: "b",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "third",
|
|
|
|
|
|
|
|
val: "a",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionDel,
|
|
|
|
|
|
|
|
key: "first",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
act: actionDel,
|
|
|
|
act: actionDel,
|
|
|
|
key: "second",
|
|
|
|
key: "second",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
expect: []string{"a"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "add three, dup values, delete two, delete not added",
|
|
|
|
|
|
|
|
do: []action{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "first",
|
|
|
|
|
|
|
|
val: "a",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "second",
|
|
|
|
val: "b",
|
|
|
|
val: "b",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionAdd,
|
|
|
|
|
|
|
|
key: "third",
|
|
|
|
|
|
|
|
val: "a",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionDel,
|
|
|
|
|
|
|
|
key: "first",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expect: []string{},
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionDel,
|
|
|
|
|
|
|
|
key: "second",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
act: actionDel,
|
|
|
|
|
|
|
|
key: "forth",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
expect: []string{"a"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exclusives := []bool{true, false}
|
|
|
|
for _, test := range tests {
|
|
|
|
for _, test := range tests {
|
|
|
|
|
|
|
|
for _, exclusive := range exclusives {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
c := newContainer(false)
|
|
|
|
c := newContainer(exclusive)
|
|
|
|
for _, order := range test.do {
|
|
|
|
for _, order := range test.do {
|
|
|
|
if order.act == actionAdd {
|
|
|
|
if order.act == actionAdd {
|
|
|
|
c.OnAdd(internal.KV{
|
|
|
|
c.OnAdd(internal.KV{
|
|
|
@ -130,3 +189,4 @@ func TestContainer(t *testing.T) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|