more updates for setting output
This commit is contained in:
@@ -12,15 +12,16 @@ RSpec.describe OutputWriter do
|
||||
describe "#set_output" do
|
||||
let(:name) { "var_name" }
|
||||
let(:value) { "var_value" }
|
||||
let(:output) { "#{name}=#{value}" }
|
||||
|
||||
subject { test_class.set_output(name, value) }
|
||||
|
||||
it { expect { subject }.to output(/::set-output name=#{name}::#{value}/).to_stdout }
|
||||
it { expect { subject }.to change { File.readlines(ENV["GITHUB_OUTPUT"], chomp: true).last }.to(/#{output}/) }
|
||||
|
||||
context "when value is nil" do
|
||||
let(:value) { nil }
|
||||
|
||||
it { expect { subject }.not_to output(/::set-output name=#{name}::#{value}/).to_stdout }
|
||||
it { expect { subject }.not_to change { File.read(ENV["GITHUB_OUTPUT"], chomp: true).last } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,6 +104,6 @@ RSpec.describe Command do
|
||||
COMMENT
|
||||
end
|
||||
|
||||
it { expect { subject }.to output(/::set-output name=command::audit/).to_stdout }
|
||||
it { expect { subject }.to change { File.readlines(ENV["GITHUB_OUTPUT"], chomp: true).last }.to("command=audit") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,6 +52,12 @@ RSpec.describe Provider do
|
||||
|
||||
it { expect { subject }.not_to raise_error }
|
||||
end
|
||||
|
||||
context "when a provider is a quoted string" do
|
||||
let(:labels) { "[ \"jenkins\" ]" }
|
||||
|
||||
it { expect { subject }.not_to raise_error }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#cli_command" do
|
||||
@@ -92,6 +98,6 @@ RSpec.describe Provider do
|
||||
LABELS
|
||||
end
|
||||
|
||||
it { expect { subject }.to output(/::set-output name=provider::azure-devops/).to_stdout }
|
||||
it { expect { subject }.to change { File.readlines(ENV["GITHUB_OUTPUT"], chomp: true).last }.to("provider=azure-devops") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require "bundler/setup"
|
||||
require "factory_bot"
|
||||
require "faker"
|
||||
require "fileutils"
|
||||
|
||||
require_relative "./../cli"
|
||||
|
||||
@@ -25,5 +26,12 @@ RSpec.configure do |config|
|
||||
|
||||
config.before(:suite) do
|
||||
FactoryBot.find_definitions
|
||||
Dir.mkdir("tmp") unless Dir.exist?("tmp")
|
||||
FileUtils.touch "tmp/test.txt"
|
||||
ENV["GITHUB_OUTPUT"] = "tmp/test.txt"
|
||||
end
|
||||
|
||||
config.after(:suite) do
|
||||
File.delete("tmp/test.txt")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user