Skip to content

Commit bfd201c

Browse files
committed
schema: move 'concurrent schema update' error to constants
Closes #TNTP-3336
1 parent 20494e9 commit bfd201c

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

schema.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const (
1919
vspaceSpFormatFieldNum = 7
2020
)
2121

22+
var (
23+
ErrConcurrentSchemaUpdate = errors.New("concurrent schema update")
24+
)
25+
2226
func msgpackIsUint(code byte) bool {
2327
return code == msgpcode.Uint8 || code == msgpcode.Uint16 ||
2428
code == msgpcode.Uint32 || code == msgpcode.Uint64 ||
@@ -415,7 +419,7 @@ func GetSchema(doer Doer) (Schema, error) {
415419
schema.SpacesById[spaceId].IndexesById[index.Id] = index
416420
schema.SpacesById[spaceId].Indexes[index.Name] = index
417421
} else {
418-
return Schema{}, errors.New("concurrent schema update")
422+
return Schema{}, ErrConcurrentSchemaUpdate
419423
}
420424
}
421425

tarantool_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,14 +3999,13 @@ func TestConnect_schema_update(t *testing.T) {
39993999
for i := 0; i < 100; i++ {
40004000
fut := conn.Do(NewCallRequest("create_spaces"))
40014001

4002-
if conn, err := Connect(ctx, dialer, opts); err != nil {
4003-
if err.Error() != "concurrent schema update" {
4004-
t.Errorf("unexpected error: %s", err)
4005-
}
4006-
} else if conn == nil {
4007-
t.Errorf("conn is nil")
4008-
} else {
4009-
conn.Close()
4002+
switch conn, err := Connect(ctx, dialer, opts); {
4003+
case err != nil:
4004+
assert.ErrorIs(t, err, ErrConcurrentSchemaUpdate)
4005+
case conn == nil:
4006+
assert.Fail(t, "conn is nil")
4007+
default:
4008+
_ = conn.Close()
40104009
}
40114010

40124011
if _, err := fut.Get(); err != nil {

0 commit comments

Comments
 (0)