From 35e8d8b95e8f67962b7dfb5d1578cbfcc0c34e37 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Wed, 14 Oct 2015 13:59:57 +0200 Subject: [PATCH] Moved DeviceName tests from old to new testsuite --- test/routines_test.rb | 22 +++++++++++++++ testsuite/tests/hardware.err | 0 testsuite/tests/hardware.out | 4 --- testsuite/tests/hardware.rb | 53 ------------------------------------ 4 files changed, 22 insertions(+), 57 deletions(-) delete mode 100644 testsuite/tests/hardware.err delete mode 100644 testsuite/tests/hardware.out delete mode 100644 testsuite/tests/hardware.rb diff --git a/test/routines_test.rb b/test/routines_test.rb index ae8e3f4e4..107876af2 100755 --- a/test/routines_test.rb +++ b/test/routines_test.rb @@ -59,3 +59,25 @@ def initialize expect(routines.ValidNicName("eth0?")).to be false end end + +describe "#DeviceName" do + subject(:routines) { RoutinesTestClass.new } + let(:hwinfo) do + { + "sub_vendor" => "hw_vendor", + "sub_device" => "hw_device" + } + end + + it "returns empty string when nothing is defined" do + expect(routines.DeviceName({})).to be_empty + end + + it "returns description containing model name when known" do + expect(routines.DeviceName(hwinfo.merge("model" => "hw_model"))).to eql "hw_model" + end + + it "returns description build from vendor and device details when model name is uknown" do + expect(routines.DeviceName(hwinfo)).to eql "hw_vendor hw_device" + end +end diff --git a/testsuite/tests/hardware.err b/testsuite/tests/hardware.err deleted file mode 100644 index e69de29bb..000000000 diff --git a/testsuite/tests/hardware.out b/testsuite/tests/hardware.out deleted file mode 100644 index 635f4ab0a..000000000 --- a/testsuite/tests/hardware.out +++ /dev/null @@ -1,4 +0,0 @@ -Dump DeviceName -Return -Return hwmodel -Return hwvendor hwdevice diff --git a/testsuite/tests/hardware.rb b/testsuite/tests/hardware.rb deleted file mode 100644 index 202e2f957..000000000 --- a/testsuite/tests/hardware.rb +++ /dev/null @@ -1,53 +0,0 @@ -# encoding: utf-8 - -# *************************************************************************** -# -# Copyright (c) 2012 Novell, Inc. -# 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 Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, -# you may find current contact information at www.novell.com -# -# ************************************************************************** -module Yast - class HardwareClient < Client - def main - Yast.import "UI" - - # testedfiles: hardware.ycp Testsuite.ycp - Yast.import "Testsuite" - @READ = { "target" => { "tmpdir" => "/tmp", "stat" => {} } } - Testsuite.Init([@READ], 0) - - @description = "" - @type = "" - @unique = "" - @hotplug = "" - @Requires = [] - Yast.include self, "network/hardware.rb" - - Testsuite.Dump("DeviceName") - Testsuite.Test(-> { DeviceName({}) }, [], nil) - Testsuite.Test(-> { DeviceName("model" => "hwmodel") }, [], nil) - Testsuite.Test(lambda do - DeviceName("sub_vendor" => "hwvendor", "sub_device" => "hwdevice") - end, [], nil) - - nil - end - end -end - -Yast::HardwareClient.new.main