24 require_once (__DIR__ .
"/../../../testing/db/createEmptyTestEnvironment.php");
32 public $EXE_PATH =
"";
34 public $DB_COMMAND =
"";
39 protected function setUp() {
47 list($test_name, $DB_CONF, $DB_NAME, $PG_CONN) = setupTestEnv($cwd,
"delagent",
false);
49 $EXE_PATH =
'../../agent/delagent';
53 if(file_exists($EXE_PATH))
55 $usage =
'Usage: ../../agent/delagent [options]';
56 $usageL =
' -f :: List folder IDs.';
60 $this->assertFileExists($EXE_PATH,
61 $message =
'FATAL: cannot find executable file, stop testing\n');
64 $EXE_PATH = $EXE_PATH.
" -c $DB_CONF";
65 $last = exec(
"$EXE_PATH -h 2>&1", $out, $rtn);
66 $this->assertEquals($usage, $out[0]);
67 $this->assertEquals($usageL, $out[6]);
85 $db_array = parse_ini_file(
"$DB_CONF/Db.conf");
86 $db_user = $db_array[
"user"];
88 exec(
"gunzip -c ../testdata/testdb_all.gz | psql -U $db_user -d $DB_NAME >/dev/null");
90 $sql =
"SELECT upload_pk, upload_filename FROM upload ORDER BY upload_pk;";
91 $result = pg_query($PG_CONN, $sql);
92 if (pg_num_rows($result) > 0){
93 $row = pg_fetch_assoc($result);
94 $expected = $row[
"upload_pk"] .
" :: ". $row[
"upload_filename"];
96 pg_free_result($result);
98 $command =
"$EXE_PATH -u -n fossy -p fossy";
99 exec($command, $out, $rtn);
101 $this->assertStringStartsWith($expected, $out[1]);
121 $db_array = parse_ini_file(
"$DB_CONF/Db.conf");
122 $db_user = $db_array[
"user"];
124 exec(
"gunzip -c ../testdata/testdb_all.gz | psql -U $db_user -d $DB_NAME >/dev/null");
126 $sql =
"SELECT folder_pk,parent,name,description,upload_pk FROM folderlist ORDER BY name,parent,folder_pk;";
127 $result = pg_query($PG_CONN, $sql);
128 if (pg_num_rows($result) > 0){
129 $row = pg_fetch_assoc($result);
130 $expected =
" -- :: Contains: " . $row[
"name"];
132 pg_free_result($result);
133 $command =
"$EXE_PATH -f -n fossy -p fossy";
134 exec($command, $out, $rtn);
135 #print $expected . "\n"; 136 #print $out[1] . "\n"; 137 $this->assertStringStartsWith($expected, $out[2]);
153 $expected =
"The upload '2' is deleted by the user 'fossy'.";
155 $db_array = parse_ini_file(
"$DB_CONF/Db.conf");
156 $db_user = $db_array[
"user"];
158 exec(
"gunzip -c ../testdata/testdb_all.gz | psql -U $db_user -d $DB_NAME >/dev/null");
159 $sql =
"UPDATE upload SET user_fk = 3;";
160 $result = pg_query($PG_CONN, $sql);
161 pg_free_result($result);
163 $command =
"$EXE_PATH -U 2 -n fossy -p fossy";
164 exec($command, $out, $rtn);
165 #print $expected . "\n"; 166 #print $out[1] . "\n"; 167 $sql =
"SELECT upload_fk, uploadtree_pk FROM bucket_container, uploadtree WHERE uploadtree_fk = uploadtree_pk AND upload_fk = 2;";
168 $result = pg_query($PG_CONN, $sql);
169 if (pg_num_rows($result) > 0){
170 $this->assertFalse(
"bucket_container records not deleted!");
172 pg_free_result($result);
174 $this->assertStringStartsWith($expected, $out[0]);
188 exec(
"$DB_COMMAND -d $DB_NAME");
189 exec(
"rm -rf $DB_CONF");
testDelagentu()
test delagent -u
test the delagent agent thru command line.
testDelagentf()
test delagent -f
testDelagentUpload()
test delagent -U 2
list_t type structure used to keep various lists. (e.g. there are multiple lists).