Skip to content

Commit

Permalink
test: add more unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
  • Loading branch information
GuptaManan100 authored and arthurschreiber committed Nov 8, 2024
1 parent d77fae7 commit b0e2f64
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions go/vt/vtgate/buffer/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vterrors"

Expand Down Expand Up @@ -68,6 +70,32 @@ var (
}
)

func TestIsErrorDueToReparenting(t *testing.T) {
testcases := []struct {
err error
want bool
}{
{
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, ClusterEventReshardingInProgress),
want: false,
},
{
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, ClusterEventReparentInProgress),
want: true,
},
{
err: vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, "The MySQL server is running with the --super-read-only option"),
want: true,
},
}
for _, tt := range testcases {
t.Run(tt.err.Error(), func(t *testing.T) {
got := IsErrorDueToReparenting(tt.err)
assert.Equal(t, tt.want, got)
})
}
}

func TestBuffering(t *testing.T) {
testAllImplementations(t, testBuffering1)
}
Expand Down

0 comments on commit b0e2f64

Please sign in to comment.