Skip to content

Commit

Permalink
Merge pull request #21 from yast/drop_old_testsuite
Browse files Browse the repository at this point in the history
Drop old testsuite
  • Loading branch information
jreidinger committed Mar 26, 2020
2 parents bb424e8 + 13496f6 commit 1f11f91
Show file tree
Hide file tree
Showing 19 changed files with 176 additions and 371 deletions.
31 changes: 1 addition & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
Makefile
Makefile.am
Makefile.in
aclocal.m4
autom4te.cache
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.ac
depcomp
install-sh
*.pot
libtool
ltconfig
ltmain.sh
missing
mkinstalldirs
stamp-h*
Makefile.am.common
*.ami
*.bz2
.dep
Expand All @@ -31,10 +8,4 @@ tmp.*
*.bak
.yardoc/
/doc/autodocs/
/testsuite/config
/testsuite/raw.*
/testsuite/*.sum
/testsuite/*.exp
/testsuite/run/runtest.sh
/testsuite/yast2-nis-server.test/

/coverage
23 changes: 0 additions & 23 deletions Makefile.cvs

This file was deleted.

Empty file removed agents/Makefile.am
Empty file.
13 changes: 0 additions & 13 deletions configure.in.in

This file was deleted.

34 changes: 0 additions & 34 deletions doc/images/Makefile.am

This file was deleted.

8 changes: 6 additions & 2 deletions package/yast2-nis-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ Url: https://github.com/yast/yast-nis-server

Source0: %{name}-%{version}.tar.bz2

BuildRequires: doxygen perl-XML-Writer update-desktop-files yast2-network yast2-nis-client yast2-testsuite
BuildRequires: update-desktop-files yast2-network yast2-nis-client
# SuSEFirewall2 replaced by firewalld (fate#323460)
BuildRequires: yast2 >= 4.0.39
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)

Requires: yast2-network yast2-nis-client
# SuSEFirewall2 replaced by firewalld (fate#323460)
Expand All @@ -52,8 +54,10 @@ similar to yellow pages.
%prep
%setup -q

%check
%yast_check

%build
%yast_build

%install
%yast_install
Expand Down
42 changes: 0 additions & 42 deletions src/Makefile.am

This file was deleted.

96 changes: 96 additions & 0 deletions test/nis_server_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
require_relative "test_helper"

Yast.import "NisServer"

describe "Yast::NisServer" do
subject { Yast::NisServer }
describe "#getMaster" do
it "returns nil if domain is empty" do
subject.domain = ""
expect(subject.getMaster).to eq nil
end

it "returns nil if domain directory does not exist" do
subject.domain = "test"
allow(Yast::SCR).to receive(:Read).with(path(".target.size"), "/var/yp/test").and_return(-1)

expect(subject.getMaster).to eq nil
end

it "returns nil if domain directory is empty" do
subject.domain = "test"
allow(Yast::SCR).to receive(:Read).with(path(".target.size"), "/var/yp/test").and_return(0)
allow(Yast::SCR).to receive(:Read).with(path(".target.dir"), "/var/yp/test").and_return([])

expect(subject.getMaster).to eq nil
end

it "returns master server name" do
subject.domain = "test"
allow(Yast::SCR).to receive(:Read).with(path(".target.size"), "/var/yp/test").and_return(0)
allow(Yast::SCR).to receive(:Read).with(path(".target.dir"), "/var/yp/test").and_return(["a"])
allow(Yast::SCR).to receive(:Execute)
.with(
path(".target.bash_output"),
"/usr/lib/yp/makedbm -u /var/yp/test/a | grep ^YP_MASTER_NAME")
.and_return("exit" => 0, "stdout" => "YP_MASTER_NAME expected")

expect(subject.getMaster).to eq "expected"
end
end

describe "isYPMaster" do
it "returns false if master is nil" do
allow(subject).to receive(:getMaster).and_return(nil)

expect(subject.isYPMaster).to eq false
end

it "returns true if master is same as hostname" do
allow(subject).to receive(:getMaster).and_return("test")
allow(Yast::SCR).to receive(:Execute)
.with(
path(".target.bash_output"),
"/usr/lib/yp/yphelper --hostname")
.and_return("exit" => 0, "stdout" => "test")

expect(subject.isYPMaster).to eq true
end
end

describe "#SaveVariables" do
context ":slave is passed" do
it "writes default domain" do
subject.domain = "test"
expect(Yast::SCR).to receive(:Write).with(path(".etc.defaultdomain"), "test")

subject.SaveVariables(:slave)
end
end

context ":master is passed" do
before do
allow(Yast::SCR).to receive(:Write)
end

it "writes default domain" do
subject.domain = "test"
expect(Yast::SCR).to receive(:Write).with(path(".etc.defaultdomain"), "test")

subject.SaveVariables(:master)
end

it "writes variables to /etc/sysconfig/ypserv" do
expect(Yast::SCR).to receive(:Write).with(path(".sysconfig.ypserv"), nil)

subject.SaveVariables(:master)
end

it "writes variables to /var/yp/Makefile" do
expect(Yast::SCR).to receive(:Write).with(path(".var.yp.makefile"), nil)

subject.SaveVariables(:master)
end
end
end
end
29 changes: 29 additions & 0 deletions test/routines_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative "test_helper"

class TestClass < Yast::Client
def initialize
Yast.include self, "nis_server/routines.rb"
end
end

describe "RoutinesInclude" do
subject { TestClass.new }

describe "#toboolean" do
it "converts value to boolean" do
["true", 1, true].each do |v|
expect(subject.toboolean(v)).to eq true
end

["false", 0, false].each do |v|
expect(subject.toboolean(v)).to eq false
end
end

it "returns false for unknown values" do
[[], {}, nil, :symbol].each do |v|
expect(subject.toboolean(v)).to eq false
end
end
end
end
44 changes: 44 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

ENV["Y2DIR"] = File.expand_path("../src", __dir__)

# localization agnostic tests
ENV["LC_ALL"] = "en_US.utf-8"
ENV["LANG"] = "en_US.utf-8"

require "yast"
require "yast/rspec"

# force utf-8 encoding for external
Encoding.default_external = Encoding::UTF_8

RSpec.configure do |config|
config.mock_with :rspec do |mocks|
# If you misremember a method name both in code and in tests,
# will save you.
# https://relishapp.com/rspec/rspec-mocks/v/3-0/docs/verifying-doubles/partial-doubles
#
# With graceful degradation for RSpec 2
mocks.verify_partial_doubles = true if mocks.respond_to?(:verify_partial_doubles=)
end
end

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start do
add_filter "/test/"
end

src_location = File.expand_path("../src", __dir__)
# track all ruby files under src
SimpleCov.track_files("#{src_location}/**/*.rb")

# use coveralls for on-line code coverage reporting at Travis CI
if ENV["TRAVIS"]
require "coveralls"
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
end
end
21 changes: 0 additions & 21 deletions testsuite/Makefile.am

This file was deleted.

Empty file removed testsuite/tests/GetSaveList.err
Empty file.
3 changes: 0 additions & 3 deletions testsuite/tests/GetSaveList.out

This file was deleted.

Empty file removed testsuite/tests/SaveVariables.err
Empty file.
16 changes: 0 additions & 16 deletions testsuite/tests/SaveVariables.out

This file was deleted.

0 comments on commit 1f11f91

Please sign in to comment.