Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c6a61b
commit 777c11c
Showing
2 changed files
with
51 additions
and
1 deletion.
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 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,48 @@ | ||
#!/usr/bin/env rspec | ||
|
||
require_relative "test_helper" | ||
require "yast2/execute" | ||
|
||
Yast.import "Report" | ||
|
||
describe Yast::Execute do | ||
it "sets yast logger as cheetah logger" do | ||
expect(Cheetah.default_options[:logger]).to eq Yast::Y2Logger.instance | ||
end | ||
|
||
describe ".locally" do | ||
it "passes arguments directly to cheetah" do | ||
expect(Cheetah).to receive(:run).with("ls", "-a") | ||
|
||
Yast::Execute.locally("ls", "-a") | ||
end | ||
|
||
it "report error if command execution failed" do | ||
expect(Yast::Report).to receive(:Error) | ||
Yast::Execute.locally("false") | ||
end | ||
|
||
it "returns nil if command execution failed" do | ||
expect(Yast::Execute.locally("false")).to eq nil | ||
end | ||
end | ||
|
||
describe ".on_target" do | ||
it "adds to passed arguments chroot option if scr chrooted" do | ||
Yast::Installation.destdir = "/mnt" | ||
allow(Yast::WFM).to receive(:scr_chrooted?).and_return(true) | ||
expect(Cheetah).to receive(:run).with("ls", "-a", chroot: "/mnt") | ||
|
||
Yast::Execute.on_target("ls", "-a") | ||
end | ||
|
||
it "report error if command execution failed" do | ||
expect(Yast::Report).to receive(:Error) | ||
Yast::Execute.on_target("false") | ||
end | ||
|
||
it "returns nil if command execution failed" do | ||
expect(Yast::Execute.on_target("false")).to eq nil | ||
end | ||
end | ||
end |