more updates for setting output

This commit is contained in:
Ethan Dennis
2023-02-28 09:18:02 -08:00
committed by GitHub
parent 94acf2f4f2
commit 6acf71f389
7 changed files with 25 additions and 8 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ jobs:
unit-test: unit-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: ${{ env.ruby_version }} ruby-version: ${{ env.ruby_version }}
@@ -25,7 +25,7 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: ${{ env.ruby_version }} ruby-version: ${{ env.ruby_version }}
+1 -1
View File
@@ -48,7 +48,7 @@ jobs:
repo: context.repo.repo, repo: context.repo.repo,
labels: ['actions-importer-running'] labels: ['actions-importer-running']
}) })
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.7.1 ruby-version: 2.7.1
+3 -1
View File
@@ -4,6 +4,8 @@ module OutputWriter
def set_output(name, value) def set_output(name, value)
return if value.nil? return if value.nil?
puts "::set-output name=#{name}::#{value}" File.open(ENV["GITHUB_OUTPUT"], "a") do |f|
f.puts "#{name}=#{value}"
end
end end
end end
+3 -2
View File
@@ -12,15 +12,16 @@ RSpec.describe OutputWriter do
describe "#set_output" do describe "#set_output" do
let(:name) { "var_name" } let(:name) { "var_name" }
let(:value) { "var_value" } let(:value) { "var_value" }
let(:output) { "#{name}=#{value}" }
subject { test_class.set_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 context "when value is nil" do
let(:value) { nil } 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 end
end end
+1 -1
View File
@@ -104,6 +104,6 @@ RSpec.describe Command do
COMMENT COMMENT
end 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
end end
+7 -1
View File
@@ -52,6 +52,12 @@ RSpec.describe Provider do
it { expect { subject }.not_to raise_error } it { expect { subject }.not_to raise_error }
end end
context "when a provider is a quoted string" do
let(:labels) { "[ \"jenkins\" ]" }
it { expect { subject }.not_to raise_error }
end
end end
describe "#cli_command" do describe "#cli_command" do
@@ -92,6 +98,6 @@ RSpec.describe Provider do
LABELS LABELS
end 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
end end
+8
View File
@@ -3,6 +3,7 @@
require "bundler/setup" require "bundler/setup"
require "factory_bot" require "factory_bot"
require "faker" require "faker"
require "fileutils"
require_relative "./../cli" require_relative "./../cli"
@@ -25,5 +26,12 @@ RSpec.configure do |config|
config.before(:suite) do config.before(:suite) do
FactoryBot.find_definitions 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
end end