Fix ResourceTest

pull/59/head
Vitaliy Filippov 2016-01-06 12:55:02 +03:00
parent 4a4e22026b
commit 86acd18978
3 changed files with 8 additions and 5 deletions

View File

@ -164,6 +164,7 @@ void Resource::FromRemoteFile( const Entry& remote )
}
// local not exists
// FIXME: Remove additional stat() call here
else if ( !fs::exists( path ) )
{
Trace( "file %1% change stamp = %2%", Path(), remote.ChangeStamp() ) ;
@ -704,7 +705,7 @@ std::string Resource::MD5() const
bool Resource::IsRoot() const
{
// Root entry does not show up in file feeds, so we check for empty parent (and self-href)
return m_parent == 0 ;
return !m_parent ;
}
bool Resource::HasID() const

View File

@ -40,8 +40,8 @@ ResourceTest::ResourceTest( )
void ResourceTest::TestRootPath()
{
std::string rootFolder = "/home/usr/grive/grive";
Resource root(rootFolder) ;
std::string rootFolder = "/home/usr/grive/grive";
Resource root( rootFolder ) ;
CPPUNIT_ASSERT( root.IsRoot() ) ;
GRUT_ASSERT_EQUAL( root.Path(), fs::path( rootFolder ) ) ;
}
@ -52,20 +52,23 @@ void ResourceTest::TestNormal( )
Resource subject( "entry.xml", "file" ) ;
root.AddChild( &subject ) ;
GRUT_ASSERT_EQUAL( subject.IsRoot(), false ) ;
GRUT_ASSERT_EQUAL( subject.Path(), fs::path( TEST_DATA ) / "entry.xml" ) ;
Val st;
st.Add( "srv_time", Val( DateTime( "2012-05-09T16:13:22.401Z" ).Sec() ) );
subject.FromLocal( st ) ;
GRUT_ASSERT_EQUAL( subject.MD5(), "c0742c0a32b2c909b6f176d17a6992d0" ) ;
GRUT_ASSERT_EQUAL( subject.StateStr(), "local_new" ) ;
xml::Node entry = xml::Node::Element( "entry" ) ;
entry.AddElement( "updated" ).AddText( "2012-05-09T16:13:22.401Z" ) ;
entry.AddElement( "docs:md5Checksum" ).AddText( "DIFFERENT" ) ;
Entry1 remote( entry ) ;
GRUT_ASSERT_EQUAL( "different", remote.MD5() ) ;
subject.FromRemote( remote ) ;
GRUT_ASSERT_EQUAL( "local_changed", subject.StateStr() ) ;
}
} // end of namespace grut

View File

@ -1 +0,0 @@
{ "change_stamp": "", "rtree": { "name": ".", "id": "folder:root", "href": "https:\/\/docs.google.com\/feeds\/default\/private\/full\/folder%3Aroot", "md5": "", "kind": "folder", "mtime": { "sec": 0, "nsec": 0 }, "child": [ { "name": "entry.xml", "id": "", "href": "", "md5": "c0742c0a32b2c909b6f176d17a6992d0", "kind": "file", "mtime": { "sec": 1336796872, "nsec": 404985662 }, "child": [ ] } ] } }