-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added logic for working with Tarantool schema via Box #426
Conversation
2e271da
to
9f736f4
Compare
07de408
to
0a3720b
Compare
0a3720b
to
3155a23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add more unit-tests for a new requests/response. You could see how it is tested on the main package and inside the crud
subpackage.
We also need examples (in example_test.go) with new features. This will help users to use the library.
Finally, we need to keep a backward compatibility until a next major release, so we need to add another Info() method with a context instead of changing the current one.
5c9bb77
to
1e3625c
Compare
i removed interface changes |
1e3625c
to
75e1930
Compare
c729ca9
to
54b7b75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, fix the commit message:
box: ddded logic for working with Tarantool schema
Implemented the `box.Schema()` method that returns a `Schema`
object for schema-related operations
b82d157
to
e8b3f1f
Compare
done |
e8b3f1f
to
40555ec
Compare
Implemented the `box.Schema()` method that returns a `Schema` object for schema-related operations
40555ec
to
4954fc7
Compare
t.Run("internal sugar sub-objects not panics", func(t *testing.T) { | ||
require.NotNil(t, b) | ||
require.NotNil(t, b.User()) | ||
}) | ||
|
||
t.Run("check that connections are equal", func(t *testing.T) { | ||
var tCases []tarantool.Doer | ||
for i := 0; i < 10; i++ { | ||
|
||
doer := test_helpers.NewMockDoer(t) | ||
tCases = append(tCases, &doer) | ||
} | ||
|
||
for _, tCase := range tCases { | ||
sch := NewSchema(tCase) | ||
require.Equal(t, tCase, sch.conn) | ||
require.Equal(t, tCase, sch.User().conn) | ||
} | ||
}) | ||
|
||
t.Run("nil conn panics", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, split it into 3 separate tests.
t.Run("can connect with new credentials", func(t *testing.T) { | ||
t.Parallel() | ||
// Check that password is valid and we can connect to tarantool with such credentials | ||
var newUserDialer = tarantool.NetDialer{ | ||
Address: server, | ||
User: username, | ||
Password: password, | ||
} | ||
|
||
// We can connect with our new credentials | ||
newUserConn, err := tarantool.Connect(ctx, newUserDialer, tarantool.Opts{}) | ||
require.NoError(t, err) | ||
require.NotNil(t, newUserConn) | ||
require.NoError(t, newUserConn.Close()) | ||
}) | ||
t.Run("create user already exists error", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, please, split it into separate tests instead of the nesting.
|
||
b := box.New(conn) | ||
|
||
t.Run("drop user after create", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
|
||
b := box.New(conn) | ||
|
||
t.Run("user not found", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
|
||
b := box.New(conn) | ||
|
||
t.Run("test user privileges is correct", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
err = b.Schema().User().Create(ctx, username, box.UserCreateOptions{Password: password}) | ||
require.NoError(t, err) | ||
|
||
t.Run("can`t grant without su permissions", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
err = b.Schema().User().Create(ctx, username, box.UserCreateOptions{Password: password}) | ||
require.NoError(t, err) | ||
|
||
t.Run("can`t revoke without su permissions", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
|
||
b := box.New(conn) | ||
|
||
t.Run("su with call", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
box.Schema()
method that returns aSchema
object for schema-related operationsWhat has been done? Why? What problem is being solved?
I didn't forget about (remove if it is not applicable):
Related issues: