Skip to content

Commit

Permalink
added more testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Feb 4, 2020
1 parent 7741047 commit 74adc01
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
6 changes: 2 additions & 4 deletions library/general/src/lib/cfa/sysctl_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def save

# Whether there is a conflict with given attributes
#
# @param only [Array<String,Symbol>] attributes to check
# @param only [Array<Symbol>] attributes to check
# @return [Array<String>] list of conflicting files
def conflict_files(only: [])
return [] if yast_config_file.empty?
Expand All @@ -116,9 +116,7 @@ def conflict_files(only: [])
# Checking all "higher" files if their values overrule the current
# YAST settings.
higher_attr = file.present_attributes
if conflicting_attrs.any? { |k, v| !higher_attr[k].nil? && v != higher_attr[k] }
file_list << file.file_path
end
file_list << file.file_path if conflicting_attrs.any? { |k, v| !higher_attr[k].nil? && v != higher_attr[k] }
end
file_list
end
Expand Down
28 changes: 28 additions & 0 deletions library/general/test/cfa/sysctl_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,34 @@
end
end

context "and specific attributes is given" do
context "attribute will be not found" do
it "returns empty list" do
expect(config.conflict_files(only: [:not_valid])).to be_empty
end
end

context "attribute is valid" do
context "when some main file value is overriden" do
let(:tcp_syncookies) { false }

it "returns file array" do
expect(config.conflict_files(only: [:tcp_syncookies]))
.to eq(["/etc/sysctl.conf"])
end
end

context "when no value is overriden" do
let(:tcp_syncookies) { true }

it "returns empty list" do
expect(config.conflict_files(only: [:tcp_syncookies]))
.to be_empty
end
end
end
end

context "when some main file value is overriden" do
let(:tcp_syncookies) { false }

Expand Down

0 comments on commit 74adc01

Please sign in to comment.