mirror of https://github.com/vitalif/grive2
added resource test
parent
61c01019f7
commit
d78728938f
|
@ -312,6 +312,7 @@ bool Resource::Upload( http::Agent* http, const std::string& link, const http::H
|
|||
|
||||
StdioFile file( Path(), "rb" ) ;
|
||||
|
||||
// TODO: upload in chunks
|
||||
std::string data ;
|
||||
char buf[4096] ;
|
||||
std::size_t count = 0 ;
|
||||
|
|
|
@ -38,6 +38,14 @@ Json::Json( ) :
|
|||
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( "cannot create json object" ) ) ;
|
||||
}
|
||||
|
||||
Json::Json( const char *str ) :
|
||||
m_json( ::json_object_new_string( str ) )
|
||||
{
|
||||
if ( m_json == 0 )
|
||||
BOOST_THROW_EXCEPTION(
|
||||
Error() << expt::ErrMsg( "cannot create json string \"" + std::string(str) + "\"" ) ) ;
|
||||
}
|
||||
|
||||
template <>
|
||||
Json::Json( const std::string& str ) :
|
||||
m_json( ::json_object_new_string( str.c_str() ) )
|
||||
|
|
|
@ -46,6 +46,7 @@ public :
|
|||
|
||||
Json() ;
|
||||
Json( const Json& rhs ) ;
|
||||
Json( const char *str ) ;
|
||||
~Json( ) ;
|
||||
|
||||
static Json Parse( const std::string& str ) ;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "util/DefaultLog.hh"
|
||||
|
||||
#include "drive/EntryTest.hh"
|
||||
#include "drive/ResourceTest.hh"
|
||||
#include "drive/ResourceTreeTest.hh"
|
||||
#include "drive/StateTest.hh"
|
||||
#include "util/DateTimeTest.hh"
|
||||
|
@ -40,6 +41,7 @@ int main( int argc, char **argv )
|
|||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( EntryTest::suite( ) ) ;
|
||||
runner.addTest( StateTest::suite( ) ) ;
|
||||
runner.addTest( ResourceTest::suite( ) ) ;
|
||||
runner.addTest( ResourceTreeTest::suite( ) ) ;
|
||||
runner.addTest( DateTimeTest::suite( ) ) ;
|
||||
runner.addTest( FunctionTest::suite( ) ) ;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ResourceTest.hh"
|
||||
|
||||
#include "Assert.hh"
|
||||
|
||||
#include "drive/Resource.hh"
|
||||
#include "protocol/Json.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace grut {
|
||||
|
||||
using namespace gr ;
|
||||
|
||||
ResourceTest::ResourceTest( )
|
||||
{
|
||||
}
|
||||
|
||||
void ResourceTest::TestNormal( )
|
||||
{
|
||||
Json json ;
|
||||
json.Add( "name", Json( "abc.txt" ) ) ;
|
||||
|
||||
Resource subject( json, 0 ) ;
|
||||
}
|
||||
|
||||
} // end of namespace grut
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace grut {
|
||||
|
||||
class ResourceTest : public CppUnit::TestFixture
|
||||
{
|
||||
public :
|
||||
ResourceTest( ) ;
|
||||
|
||||
// declare suit function
|
||||
CPPUNIT_TEST_SUITE( ResourceTest ) ;
|
||||
CPPUNIT_TEST( TestNormal ) ;
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private :
|
||||
void TestNormal( ) ;
|
||||
} ;
|
||||
|
||||
} // end of namespace
|
Loading…
Reference in New Issue