Re: Different with DebugString and mock test

3 views
Skip to first unread message

Angela Chen

unread,
Nov 6, 2014, 8:57:49 PM11/6/14
to gmock...@googlegroups.com, gmoc...@googlegroups.com
Just found the reason and fixed it. No business of gMock...
Thank you.

On Wed, Oct 22, 2014 at 11:17 PM, Angela Chen <angel...@google.com> wrote:
Hi guys,

I'm testing a rpc related function with gMock. The CL is here cl/77884031.

The test always fails in the following function.

TEST_F(SftpFileFactoryTest, CreateDir_success) {
  // Set a CreateRequest proto.
  proto::CreateRequest req;
  req.set_user_name("user");
  req.set_path("dir");
  req.set_permissions(__S_IFDIR);
  req.set_force(true);

  // Mock a CreateResponse proto.
  proto::CreateResponse rsp;
  rsp.set_code(sftp::filesystem::proto::OK);
  rsp.set_error_msg("OK");

  EXPECT_CALL(*mock_fs_, Create(NotNull(), Pointee(EquivToProto(req)), _, _))        // Fail place!!!!!!!!!!!!!!!!!!!!!
      .WillOnce(RespondWith(rsp));

  util::Status err(util::error::OK, "Create dir successfully");
  file::Options options;
  EXPECT_EQ(err, factory_->CreateDir("/sftpfs/user/dir", options));

  mode_t rw_mode(0600);
  file::Operation fileop;
  EXPECT_TRUE(factory_->CreateDirWithOp("/sftpfs/user/dir", rw_mode, &fileop));
}


When checking test log, we find that the value of   proto::CreateRequest req is different in DebugString and test.
In DebugString, the force is true; while in test, force is false, which is the default value of protocol setting. Acutely, it didn't get value of this field"force". This field is a newly added field. So the unit test can't get passed now :(((

link of test log 


Could you please help me to see why and how to resolve? 
Thank you.

-
Angela


Reply all
Reply to author
Forward
0 new messages