-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from yast/drop_old_testsuite
Drop old testsuite
- Loading branch information
Showing
19 changed files
with
176 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.