levy5307 commented on a change in pull request #598:
URL: https://github.com/apache/incubator-pegasus/pull/598#discussion_r486098835



##########
File path: src/server/test/pegasus_write_service_impl_test.cpp
##########
@@ -140,5 +156,66 @@ TEST_F(pegasus_write_service_impl_test, 
verify_timetag_compatible_with_version_0
     dsn::fail::teardown();
 }
 
+TEST_F(pegasus_write_service_impl_test, incr_on_absent_record)
+{
+    dsn::apps::incr_request req;
+    req.increment = 100;
+    pegasus::pegasus_generate_key(
+        req.key, dsn::string_view("hash_key"), dsn::string_view("sort_key"));
+
+    db_get_context get_ctx;
+    db_get(req.key, &get_ctx);
+    ASSERT_FALSE(get_ctx.found);
+
+    dsn::apps::incr_response resp;
+    _write_impl->incr(0, req, resp);
+    ASSERT_EQ(resp.new_value, 100);
+
+    db_get(req.key, &get_ctx);
+    ASSERT_TRUE(get_ctx.found);
+}
+
+TEST_F(pegasus_write_service_impl_test, negative_incr_and_zero_incr)
+{
+    dsn::apps::incr_request req;
+    req.increment = -100;

Review comment:
       there are too many same code, may be you can refactor it, such as using 
for look to do it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to