mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-10 16:43:35 +02:00
2020-02-20 Fred Gleason <fredg@paravelsystems.com>
* Added a 'FEEDS.AUDIENCE_METRICS' field to the database. * Incremented the database version to 316. * Added a 'Collect Audience Metrics' checkbox to the 'Feed' dialog in rdadmin(1). * Added an 'RDTransfer' base class. * Rebased 'RDDelete' to 'RDTransfer'. * Added 'sftp' support to 'RDDelete'. * Added 'file' support to 'RDDelete'. * Refactored RSS generation to occur in 'RDFeed'. * Added a 'delete_test' test harness.
This commit is contained in:
@@ -34,6 +34,7 @@ noinst_PROGRAMS = audio_convert_test\
|
||||
datedecode_test\
|
||||
dateparse_test\
|
||||
db_charset_test\
|
||||
delete_test\
|
||||
download_test\
|
||||
getpids_test\
|
||||
log_unlink_test\
|
||||
@@ -73,6 +74,9 @@ dateparse_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -l
|
||||
dist_db_charset_test_SOURCES = db_charset_test.cpp db_charset_test.h
|
||||
db_charset_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support
|
||||
|
||||
dist_delete_test_SOURCES = delete_test.cpp delete_test.h
|
||||
delete_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support
|
||||
|
||||
dist_download_test_SOURCES = download_test.cpp download_test.h
|
||||
download_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support
|
||||
|
||||
|
112
tests/delete_test.cpp
Normal file
112
tests/delete_test.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
// delete_test.cpp
|
||||
//
|
||||
// Test Rivendell file deletion routines.
|
||||
//
|
||||
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <rdapplication.h>
|
||||
#include <rddb.h>
|
||||
#include <rddelete.h>
|
||||
|
||||
#include "delete_test.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
QString err_msg;
|
||||
|
||||
username="";
|
||||
password="";
|
||||
RDDelete::ErrorCode conv_err;
|
||||
|
||||
//
|
||||
// Open the Database
|
||||
//
|
||||
rda=new RDApplication("delete_test","delete_test",DELETE_TEST_USAGE,this);
|
||||
if(!rda->open(&err_msg)) {
|
||||
fprintf(stderr,"delete_test: %s\n",(const char *)err_msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||
if(rda->cmdSwitch()->key(i)=="--username") {
|
||||
username=rda->cmdSwitch()->value(i);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(rda->cmdSwitch()->key(i)=="--password") {
|
||||
password=rda->cmdSwitch()->value(i);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(rda->cmdSwitch()->key(i)=="--target-url") {
|
||||
target_url=QUrl(rda->cmdSwitch()->value(i));
|
||||
if(target_url.isRelative()) {
|
||||
fprintf(stderr,"delete_test: URL's must be fully qualified\n");
|
||||
exit(1);
|
||||
}
|
||||
if(!target_url.isValid()) {
|
||||
fprintf(stderr,"delete_test: invalid URL\n");
|
||||
exit(1);
|
||||
}
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(!rda->cmdSwitch()->processed(i)) {
|
||||
fprintf(stderr,"delete_test: unknown command option \"%s\"\n",
|
||||
(const char *)rda->cmdSwitch()->key(i));
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Sanity Checks
|
||||
//
|
||||
if(target_url.isEmpty()) {
|
||||
fprintf(stderr,"delete_test: missing --target-url\n");
|
||||
exit(256);
|
||||
}
|
||||
|
||||
//
|
||||
// Run the Test
|
||||
//
|
||||
RDDelete *conv=new RDDelete(rda->config(),this);
|
||||
if(!conv->urlIsSupported(target_url)) {
|
||||
fprintf(stderr,"delete_test: unsupported URL scheme\n");
|
||||
exit(1);
|
||||
}
|
||||
conv->setTargetUrl(target_url);
|
||||
printf("Deleting...\n");
|
||||
conv_err=conv->
|
||||
runDelete(username,password,rda->config()->logXloadDebugData());
|
||||
printf("Result: %s\n",(const char *)RDDelete::errorText(conv_err));
|
||||
delete conv;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
new MainObject();
|
||||
return a.exec();
|
||||
}
|
43
tests/delete_test.h
Normal file
43
tests/delete_test.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// delete_test.h
|
||||
//
|
||||
// Test Rivendell remote file deletion routines.
|
||||
//
|
||||
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef DELETE_TEST_H
|
||||
#define DELETE_TEST_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qurl.h>
|
||||
|
||||
#define DELETE_TEST_USAGE "[options]\n\nTest the Rivendell deletion routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--target-url=<url>\n\n"
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
public:
|
||||
MainObject(QObject *parent=0);
|
||||
|
||||
private:
|
||||
QString username;
|
||||
QString password;
|
||||
QUrl target_url;
|
||||
};
|
||||
|
||||
|
||||
#endif // DELETE_TEST_H
|
Reference in New Issue
Block a user