Skip to content

Commit

Permalink
More mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed May 6, 2024
1 parent 05439c5 commit 8b64aeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Library/Homebrew/sbom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class SBOM
sig { params(formula: Formula, compiler: T.nilable(String), stdlib: T.nilable(String)).returns(T.attached_class) }
def self.create(formula, compiler: nil, stdlib: nil)
build = formula.build
runtime_deps = formula.runtime_dependencies(undeclared: false)
runtime_deps = formula.runtime_formula_dependencies(undeclared: false)

attributes = {
name: formula.name,
homebrew_version: HOMEBREW_VERSION,
Expand Down Expand Up @@ -297,16 +298,15 @@ def to_spdx_sbom
sig { params(formula: Formula, deps: T::Array[Dependency]).returns(T::Array[T::Hash[Symbol, String]]) }
def self.runtime_deps_hash(formula, deps)
deps.map do |dep|
f = dep.to_formula
{
full_name: f.full_name,
name: f.name,
version: f.version.to_s,
revision: f.revision,
pkg_version: f.pkg_version.to_s,
declared_directly: formula.deps.include?(dep),
license: SPDX.license_expression_to_string(f.license),
bottle: f.bottle_hash,
full_name: dep.full_name,
name: dep.name,
version: dep.version.to_s,
revision: dep.revision,
pkg_version: dep.pkg_version.to_s,
declared_directly: true,
license: SPDX.license_expression_to_string(dep.license),
bottle: dep.bottle_hash,
}
end
end
Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/test/sbom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
uses_from_macos "zlib"
end

beanstalkd = formula "beanstalkd" do
url "one-1.1"
end

zlib = formula "zlib" do
url "two-1.1"
end

allow(f).to receive_messages(
runtime_formula_dependencies: [beanstalkd, zlib]
)

sbom = described_class.create(f)
expect(sbom).to be_valid
end
Expand Down

0 comments on commit 8b64aeb

Please sign in to comment.