diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-06 19:16:55 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-06 19:16:55 +0530 |
commit | b595d89891d429606b37e2d6ad9bf99cabd473ec (patch) | |
tree | a47d16d3cc8ea1778568f772914ef62e1d043e0c /spec | |
parent | fc07ead366d5ef3acd9f7fe3dd36503e5a3ed1c5 (diff) | |
download | chef-b595d89891d429606b37e2d6ad9bf99cabd473ec.tar.gz |
Make temp dir using mkdir instead of mktemp
- mktemp does not exist for AIX system.
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/bootstrap/train_connector_spec.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/spec/unit/knife/bootstrap/train_connector_spec.rb b/spec/unit/knife/bootstrap/train_connector_spec.rb index 52345f3cde..ff6dfca5b1 100644 --- a/spec/unit/knife/bootstrap/train_connector_spec.rb +++ b/spec/unit/knife/bootstrap/train_connector_spec.rb @@ -155,21 +155,26 @@ describe Chef::Knife::Bootstrap::TrainConnector do context "under linux and unix-like" do let(:family) { "debian" } let(:name) { "ubuntu" } + let(:random) { "wScHX6" } + let(:dir) { "/tmp/chef_#{random}" } + + before do + allow(SecureRandom).to receive(:alphanumeric).with(6).and_return(random) + end + it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do - expected_command = Chef::Knife::Bootstrap::TrainConnector::MKTEMP_NIX_COMMAND + expected_command = "mkdir -p #{dir} && chown user1 '#{dir}'" expect(subject).to receive(:run_command!).with(expected_command) - .and_return double("result", stdout: "/a/path") - expect(subject).to receive(:run_command!).with("chown user1 '/a/path'") - expect(subject.temp_dir).to eq "/a/path" + .and_return double("result", stdout: "\r\n") + expect(subject.temp_dir).to eq(dir) end context "with noise in stderr" do it "uses the *nix command to create the temp dir and sets ownership to logged-in user" do - expected_command = Chef::Knife::Bootstrap::TrainConnector::MKTEMP_NIX_COMMAND + expected_command = "mkdir -p #{dir} && chown user1 '#{dir}'" expect(subject).to receive(:run_command!).with(expected_command) - .and_return double("result", stdout: "sudo: unable to resolve host hostname.localhost\r\n" + "/a/path\r\n") - expect(subject).to receive(:run_command!).with("chown user1 '/a/path'") - expect(subject.temp_dir).to eq "/a/path" + .and_return double("result", stdout: "sudo: unable to resolve host hostname.localhost\r\n" + "#{dir}\r\n") + expect(subject.temp_dir).to eq(dir) end end end |