Skip to content

Commit

Permalink
Add basic test for AyastProbe client
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 6, 2017
1 parent e717784 commit 9658fed
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/autoinstall/clients/ayast_probe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

Yast.import "UI"
Yast.import "Stage"
Yast.import "AutoInstallRules"
Yast.import "Label"

module Y2Autoinstall
module Clients
class AyastProbe
include Yast::UIShortcuts

def main
Yast.import "UI"
Yast.import "Stage"
Yast::Stage.Set("initial")
Yast.import "AutoInstallRules"
Yast.import "Label"
Yast::AutoInstallRules.ProbeRules

@attrs =
Expand Down
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TESTS = \
lib/pkg_gpg_check_handler_test.rb \
lib/storage_proposal_issues_presenter_test.rb \
lib/storage_proposal_test.rb \
lib/clients/ayast_probe_test.rb \
lib/dialogs/question_test.rb

TEST_EXTENSIONS = .rb
Expand Down
48 changes: 48 additions & 0 deletions test/lib/clients/ayast_probe_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env rspec
# encoding: utf-8

# Copyright (c) [2017] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require_relative "../../test_helper"
require "autoinstall/clients/ayast_probe"

describe Y2Autoinstall::Clients::AyastProbe do
subject(:client) { described_class.new }

before do
allow(Yast::UI).to receive(:OpenDialog).and_return(true)
allow(Yast::UI).to receive(:CloseDialog).and_return(true)
end

describe "#main" do
let(:installed_product) { "openSUSE Tumbleweed" }

before do
allow(Yast::AutoInstallRules).to receive(:installed_product)
.and_return(installed_product)
end

it "includes autoinstall rules information" do
expect(client).to receive(:RichText)
.with(/Keys for rules.*<td>installed_product<\/td><td> = <\/td><td>openSUSE Tumbleweed<br><\/td>/)
client.main
end
end
end

0 comments on commit 9658fed

Please sign in to comment.