Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

KaymeKaydex
Copy link

@KaymeKaydex KaymeKaydex commented Dec 27, 2024

  • Implemented the box.Schema() method that returns a Schema object for schema-related operations

What has been done? Why? What problem is being solved?

I didn't forget about (remove if it is not applicable):

Related issues:

@KaymeKaydex KaymeKaydex force-pushed the box/schema branch 2 times, most recently from 2e271da to 9f736f4 Compare December 27, 2024 17:51
box/box_test.go Outdated Show resolved Hide resolved
box/schema.go Show resolved Hide resolved
box/schema.go Outdated Show resolved Hide resolved
box/schema.go Outdated Show resolved Hide resolved
box/tarantool_test.go Outdated Show resolved Hide resolved
box/schema_user.go Outdated Show resolved Hide resolved
box/schema_user.go Show resolved Hide resolved
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a 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.

CHANGELOG.md Outdated Show resolved Hide resolved
@KaymeKaydex KaymeKaydex force-pushed the box/schema branch 11 times, most recently from 5c9bb77 to 1e3625c Compare January 21, 2025 15:15
@KaymeKaydex
Copy link
Author

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.

i removed interface changes
added new examples for new methods
and added more tests to make coverage up, now all methods are covered

@KaymeKaydex KaymeKaydex force-pushed the box/schema branch 10 times, most recently from c729ca9 to 54b7b75 Compare January 23, 2025 12:30
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a 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

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
box/example_test.go Outdated Show resolved Hide resolved
box/example_test.go Outdated Show resolved Hide resolved
box/example_test.go Outdated Show resolved Hide resolved
box/schema_test.go Outdated Show resolved Hide resolved
box/schema_test.go Show resolved Hide resolved
box/schema_user.go Outdated Show resolved Hide resolved
box/schema_user.go Outdated Show resolved Hide resolved
box/tarantool_test.go Outdated Show resolved Hide resolved
@KaymeKaydex KaymeKaydex force-pushed the box/schema branch 9 times, most recently from b82d157 to e8b3f1f Compare January 28, 2025 20:23
@KaymeKaydex
Copy link
Author

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

done

Implemented the `box.Schema()` method that returns a `Schema`
object for schema-related operations
Comment on lines +20 to +40
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) {
Copy link
Collaborator

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.

Comment on lines +89 to +104
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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etc

@KaymeKaydex KaymeKaydex closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants