-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] Introduce tests for workers code
Test the `bs_worker` code with `require_ok`. Add the following tests for the `getsources` subroutine: - Return result. - Add 'materials' key to $buildinfo variable (used in the SLSA provenance generation).
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 3; | ||
|
||
|
||
use FindBin; | ||
use lib "$FindBin::Bin/lib/"; | ||
|
||
use BSUtil; | ||
use Test::Mock::BSConfig; | ||
use Test::Mock::BSRPC; | ||
|
||
|
||
@::ARGV = ('--testcase'); | ||
require_ok('./bs_worker'); | ||
|
||
$BSConfig::bsdir = $FindBin::Bin; | ||
my $tmpdir = "$FindBin::Bin/tmp/1000"; | ||
mkdir($tmpdir); | ||
|
||
my $buildinfo = { | ||
srcserver => $BSConfig::srcserver, | ||
project => 'project1', | ||
package => 'package1', | ||
srcmd5 => 'f157738ddea737a2b7479996175a6cec', | ||
verifymd5 => 'f157738ddea737a2b7479996175a6cec', | ||
}; | ||
|
||
$Test::Mock::BSRPC::fixtures_map = { | ||
"srcserver/getsources?project=project1&package=package1&srcmd5=$buildinfo->{srcmd5}" | ||
=> 'data/1000/srcserver/getsources', | ||
}; | ||
|
||
my (@got, @expected); | ||
|
||
|
||
# getsources | ||
|
||
@got = getsources($buildinfo, $tmpdir); | ||
@expected = ('f157738ddea737a2b7479996175a6cec package1'); | ||
is_deeply(\@got, \@expected, 'getsources - Return value'); | ||
|
||
my $expected = [ | ||
{ | ||
'digest' => { | ||
'sha256' => 'e237d5c5ea2b4dd327d2e103afd09572286609fbc9bf43cc9609f1371b4c8dd2' | ||
}, | ||
'uri' => 'srcserver/source/project1/package1/hello_world.spec?rev=f157738ddea737a2b7479996175a6cec' | ||
} | ||
]; | ||
is_deeply($buildinfo->{'materials'}, $expected, "getsources - Add 'materials' key to \$buildinfo"); | ||
|
||
BSUtil::cleandir($tmpdir); | ||
rmdir($tmpdir); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters