Testing CRUD with Evans CLI

Evans is a powerful command-line interface for interacting with gRPC services. It can be used to test CRUD (Create, Read, Update, Delete) operations in your gRPC blog service.

Prerequisites

  • gRPC server running
  • Evans CLI installed

Connecting to the Server

Start the gRPC server.

Open a terminal and run the following command to connect to the server:

Bash

evans –address localhost:50051

Testing CRUD Operations

Create a Blog Post:

Use the rpc command to call the CreateBlogPost method:

Bash

rpc BlogService.CreateBlogPost

Enter the required fields for the blog post.

Read a Blog Post:

Use the rpc command to call the GetBlogPost method, passing the ID of the created blog post:

Bash

rpc BlogService.GetBlogPost id: “123”

Update a Blog Post:

Use the rpc command to call the UpdateBlogPost method, passing the updated blog post object.

Delete a Blog Post:

Use the rpc command to call the DeleteBlogPost method, passing the ID of the blog post to be deleted.

Example

Bash

# Create a blog post
rpc BlogService.CreateBlogPost title: "My First Blog Post" content: "This is the content of my blog post"

# Read the blog post
rpc BlogService.GetBlogPost id: "123"

# Update the blog post
rpc BlogService.UpdateBlogPost title: "Updated Title" content: "Updated content" id: "123"

# Delete the blog post
rpc BlogService.DeleteBlogPost id: "123"

Additional Tips

  • Use the help command in Evans to get information about available commands and options.
  • You can use the json flag to view responses in JSON format.
  • Use the --proto flag to specify the .proto file if necessary.
  • Consider writing scripts or automation tools to automate your testing.
ListBlog: Server & Client Implementation
Setting up gRPC

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?