Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YaST package search #434

Merged
merged 5 commits into from Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/suse/connect/version.rb
@@ -1,5 +1,5 @@
module SUSE
module Connect
VERSION = '0.3.25'
VERSION = '0.3.26'
end
end
13 changes: 13 additions & 0 deletions lib/suse/connect/yast.rb
Expand Up @@ -225,6 +225,19 @@ def status(client_params)
config = SUSE::Connect::Config.new.merge!(client_params)
Status.new(config)
end

# Provides access to the package search functionality
#
# @param query [String] package to search
# @param product [SUSE::Connect::Zypper::Product] product to base search on
# @param config_params [<Hash>] overwrites from the config file
#
# @return [Array< <Hash>>] Returns all matched packages or an empty array if no matches where found
#
# @see SUSE::Connect::PackageSearch.search
def search_package(query, product: Zypper.base_product, config_params: {})
SUSE::Connect::PackageSearch.search(query, product: product, config_params: config_params)
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions package/SUSEConnect.changes
@@ -1,4 +1,12 @@
-------------------------------------------------------------------

Wed Aug 26 14:37:17 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Update to 0.3.26
- Extend the YaST API in order to access to the package search
functionality (jsc#SLE-9109)

------------------------------------------------------------------
Tue Jun 30 13:39:05 UTC 2020 - Thomas Schmidt <tschmidt@suse.com>

- Don't fail de-activation when '-release' package already got removed
Expand Down
2 changes: 1 addition & 1 deletion package/SUSEConnect.spec
Expand Up @@ -17,7 +17,7 @@


Name: SUSEConnect
Version: 0.3.25
Version: 0.3.26
Release: 0
%define mod_name suse-connect
%define mod_full_name %{mod_name}-%{version}
Expand Down
30 changes: 30 additions & 0 deletions spec/connect/yast_spec.rb
Expand Up @@ -421,4 +421,34 @@
expect(subject.list_installer_updates(product, client_params)).to eq []
end
end

describe '.search_package' do
let(:base_product) { SUSE::Connect::Zypper::Product.new(name: 'SLES', arch: 'x86_64', version: '15.2') }
let(:results) { [{ name: 'foobar' }] }

before do
allow(SUSE::Connect::Zypper).to receive(:base_product).and_return(base_product)
allow(SUSE::Connect::PackageSearch).to receive(:search).and_return(results)
end

it 'searches for a package in the base product' do
expect(SUSE::Connect::PackageSearch).to receive(:search)
.with('foobar', product: base_product, config_params: {})
subject.search_package('foobar')
end

context 'when a product is given' do
let(:product) { SUSE::Connect::Zypper::Product.new(name: 'SLED', arch: 'x86_64', version: '15.2') }

it 'searches for a package in the given product' do
expect(SUSE::Connect::PackageSearch).to receive(:search)
.with('foobar', product: product, config_params: {})
subject.search_package('foobar', product: product)
end
end

it 'returns an array with the results' do
expect(subject.search_package('foobar')).to eq(results)
end
end
end