Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 14, 2015
1 parent 2fa2965 commit b8f5ce2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/registration/registration.rb
Expand Up @@ -126,6 +126,7 @@ def activated_products
# @param [Array<SUSE::Connect::Remote::Product>] installed_products
# @return [Array<Array<SUSE::Connect::Remote::Product>>] list of possible migrations
def migration_products(installed_products)
log.info "Loading migration products for: #{installed_products}"
migrations = SUSE::Connect::YaST.system_migrations(installed_products)
log.info "Received system migrations: #{migrations}"

Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/installed_sles12_product.yml
@@ -0,0 +1,7 @@
---
- !ruby/object:SUSE::Connect::Remote::Product
table:
:arch: x86_64
:identifier: SLES
:version: '12'
:release_type: DVD
7 changes: 7 additions & 0 deletions test/fixtures/migation_to_sles12_sp1.yml
@@ -0,0 +1,7 @@
---
- - !ruby/object:SUSE::Connect::Remote::Product
table:
:identifier: SLES
:version: '12.1'
:arch: x86_64
:release_type:
13 changes: 13 additions & 0 deletions test/registration_spec.rb
Expand Up @@ -167,4 +167,17 @@
expect { callback.call(false, context) }.to raise_error OpenSSL::X509::CertificateError
end
end

describe "#migration_products" do
let(:installed_products) { YAML.load_file(fixtures_file("installed_sles12_product.yml")) }
let(:migration_products) { YAML.load_file(fixtures_file("migation_to_sles12_sp1.yml")) }

it "returns migration products from the server" do
expect(SUSE::Connect::YaST).to receive(:system_migrations)
.with(installed_products)
.and_return(migration_products)
result = Registration::Registration.new.migration_products(installed_products)
expect(result).to eq(migration_products)
end
end
end
16 changes: 16 additions & 0 deletions test/registration_ui_test.rb
Expand Up @@ -137,4 +137,20 @@
expect(registration_ui.register_addons([addon_legacy], {})).to eq :back
end
end

describe "#migration_products" do
let(:installed_products) { YAML.load_file(fixtures_file("installed_sles12_product.yml")) }
let(:migration_products) { YAML.load_file(fixtures_file("migation_to_sles12_sp1.yml")) }

it "returns migration products from the server with UI feedback" do
allow(Yast::UI).to receive(:OpenDialog)
allow(Yast::UI).to receive(:CloseDialog)

expect(registration).to receive(:migration_products)
.with(installed_products)
.and_return(migration_products)

expect(registration_ui.migration_products(installed_products)).to eq(migration_products)
end
end
end

0 comments on commit b8f5ce2

Please sign in to comment.