Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed May 22, 2019
1 parent 21ea0da commit 4f47c1c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 66 deletions.
66 changes: 0 additions & 66 deletions test/hardware_test.rb

This file was deleted.

59 changes: 59 additions & 0 deletions test/y2network/widgets/interface_name_test.rb
@@ -0,0 +1,59 @@
# Copyright (c) [2019] 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 "cwm/rspec"

require "y2network/widgets/interface_name"

describe Y2Network::Widgets::InterfaceName do
subject { described_class.new({"IFCFGTYPE" => "eth"}) }

include_examples "CWM::ComboBox"

describe "#validate" do
let(:valid_name) { "eth0" }
let(:long_name) { "verylongcustomnicname123" }

it "passes for valid names only" do
allow(subject).to receive(:value).and_return valid_name

expect(Yast::NetworkInterfaces).to receive(:List).and_return([])
expect(subject.validate).to be true
end

# bnc#991486
it "fails for long names" do
allow(subject).to receive(:value).and_return long_name

expect(Yast::NetworkInterfaces).to receive(:List).and_return([])
expect(Yast::UI).to receive(:SetFocus)
expect(subject.validate).to be false
end

it "fails for already used names" do
allow(subject).to receive(:value).and_return valid_name
allow(Yast::NetworkInterfaces).to receive(:List).and_return [valid_name]

expect(Yast::UI).to receive(:SetFocus)
expect(subject.validate).to be false
end
end
end

0 comments on commit 4f47c1c

Please sign in to comment.