Skip to content

Commit

Permalink
add forgotten methods for modified flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 21, 2014
1 parent d438b08 commit 52e3e51
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
15 changes: 15 additions & 0 deletions library/general/src/lib/installation/auto_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def run
packages
when "Read"
read
when "GetModified"
modified?
when "SetModified"
modified
else
raise "Invalid action for auto client '#{func.inspect}'"
end
Expand Down Expand Up @@ -101,5 +105,16 @@ def packages
def read
raise NotImplementedError, "Calling abstract method 'write'"
end

# Abstract method to set flag for configuration that it is modified by autoyast.
def modified
raise NotImplementedError, "Calling abstract method 'modified'"
end

# Abstract method to query if configuration is modified and should be written.
def modified?
raise NotImplementedError, "Calling abstract method 'modified?'"
end

end
end
30 changes: 29 additions & 1 deletion library/general/test/auto_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def import(args)
args.empty? ? "import" : args
end

["export", "summary", "reset", "change", "write", "packages", "read"].each do |m|
["export", "summary", "reset", "change", "write", "packages", "read", "modified?", "modified"].each do |m|
define_method(m.to_sym) { m }
end
end
Expand Down Expand Up @@ -127,6 +127,34 @@ def import(args)
end
end

context "first client argument is GetModified" do
before do
allow(Yast::WFM).to receive(:Args).and_return(["GetModified", {}])
end

it "dispatch call to abstract method modified?" do
expect(subject.run).to eq "modified?"
end

it "raise NotImplementedError exception if abstract method not defined" do
expect{::Installation::AutoClient.run}.to raise_error(NotImplementedError)
end
end

context "first client argument is SetModified" do
before do
allow(Yast::WFM).to receive(:Args).and_return(["SetModified", {}])
end

it "dispatch call to abstract method modified" do
expect(subject.run).to eq "modified"
end

it "raise NotImplementedError exception if abstract method not defined" do
expect{::Installation::AutoClient.run}.to raise_error(NotImplementedError)
end
end

context "first client argument is Packages" do
before do
allow(Yast::WFM).to receive(:Args).and_return(["Packages", {}])
Expand Down

0 comments on commit 52e3e51

Please sign in to comment.