22 if (!function_exists(
'Traceback_uri'))
25 return 'Traceback_uri_if_desired';
69 protected function setUp() : void
71 $this->testDb =
new TestPgDb(
"copyrightSched".time());
72 $this->
dbManager = $this->testDb->getDbManager();
74 $logger =
new Logger(
"CopyrightSchedulerTest");
77 $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
88 $this->testDb->fullDestruct();
91 $this->licenseDao =
null;
106 $sysConf = $this->testDb->getFossSysConf();
108 $agentName =
"copyright";
110 $agentDir = dirname(__DIR__, 4) .
'/build/src/copyright';
111 $execDir =
"$agentDir/agent";
112 system(
"install -D $agentDir/VERSION-copyright $sysConf/mods-enabled/$agentName/VERSION");
113 system(
"install -D $agentDir/agent/copyright.conf $sysConf/mods-enabled/$agentName/agent/copyright.conf");
114 $pCmd =
"echo $uploadId | $execDir/$agentName -c $sysConf --scheduler_start";
115 $pipeFd = popen($pCmd,
"r");
116 $this->assertTrue($pipeFd !==
false,
'running copyright failed');
119 while (($buffer = fgets($pipeFd, 4096)) !==
false) {
122 $retCode = pclose($pipeFd);
124 unlink(
"$sysConf/mods-enabled/$agentName/VERSION");
125 unlink(
"$sysConf/mods-enabled/$agentName/agent/copyright.conf");
126 rmdir(
"$sysConf/mods-enabled/$agentName/agent/");
127 rmdir(
"$sysConf/mods-enabled/$agentName");
128 rmdir(
"$sysConf/mods-enabled");
129 unlink($sysConf.
"/fossology.conf");
131 $this->assertEquals($retCode, 0,
"copyright failed ($retCode): $output [$pCmd]");
140 $sysConf = $this->testDb->getFossSysConf();
143 $this->testInstaller->init();
144 $this->testInstaller->cpRepo();
152 $sysConf = $this->testDb->getFossSysConf();
153 system(
"rm $sysConf/repo -rf");
161 $this->testDb->createPlainTables(array(
'agent',
'uploadtree',
'upload',
'pfile',
'users',
'bucketpool',
'mimetype',
'ars_master',
'author',
'copyright_event'));
162 $this->testDb->createSequences(array(
'agent_agent_pk_seq',
'upload_upload_pk_seq',
'pfile_pfile_pk_seq',
'users_user_pk_seq',
'nomos_ars_ars_pk_seq'));
163 $this->testDb->createConstraints(array(
'agent_pkey',
'upload_pkey_idx',
'pfile_pkey',
'user_pkey'));
164 $this->testDb->alterTables(array(
'agent',
'pfile',
'upload',
'ars_master',
'users'));
165 $this->testDb->createInheritedTables(array(
'uploadtree_a'));
167 $this->testDb->insertData(array(
'upload',
'pfile',
'uploadtree_a',
'bucketpool',
'mimetype',
'users'),
false);
185 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
186 $matches = $this->copyrightDao->getAllEntries(
"copyright", $uploadId, $uploadTreeTableName);
187 $this->assertGreaterThan($expected=5, count($matches), $output);
runCopyright($uploadId)
Run copyright on a given upload id.
setUp()
Setup the test cases and initialize the objects.
tearDown()
Destruct the objects initialized during setUp()
rmRepo()
Remove the test repo.
setUpRepo()
Setup test repo mimicking install.
setUpTables()
Setup tables required by copyright agent.
Traceback_uri()
Get the URI without query to this location.
fo_dbManager * dbManager
fo_dbManager object