Skip to content

Commit b0e2f64

Browse files
GuptaManan100arthurschreiber
authored andcommitted
test: add more unit tests
Signed-off-by: Manan Gupta <[email protected]> Signed-off-by: Arthur Schreiber <[email protected]>
1 parent d77fae7 commit b0e2f64

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

go/vt/vtgate/buffer/buffer_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"testing"
2424
"time"
2525

26+
"github.com/stretchr/testify/assert"
27+
2628
"vitess.io/vitess/go/vt/topo/topoproto"
2729
"vitess.io/vitess/go/vt/vterrors"
2830

@@ -68,6 +70,32 @@ var (
6870
}
6971
)
7072

73+
func TestIsErrorDueToReparenting(t *testing.T) {
74+
testcases := []struct {
75+
err error
76+
want bool
77+
}{
78+
{
79+
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, ClusterEventReshardingInProgress),
80+
want: false,
81+
},
82+
{
83+
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, ClusterEventReparentInProgress),
84+
want: true,
85+
},
86+
{
87+
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, "The MySQL server is running with the --super-read-only option"),
88+
want: true,
89+
},
90+
}
91+
for _, tt := range testcases {
92+
t.Run(tt.err.Error(), func(t *testing.T) {
93+
got := IsErrorDueToReparenting(tt.err)
94+
assert.Equal(t, tt.want, got)
95+
})
96+
}
97+
}
98+
7199
func TestBuffering(t *testing.T) {
72100
testAllImplementations(t, testBuffering1)
73101
}

0 commit comments

Comments
 (0)