Update service and formulary specs

This commit is contained in:
apainintheneck 2023-03-21 21:55:47 -07:00
parent bc85857e13
commit e83a2562bb
2 changed files with 34 additions and 50 deletions

View File

@ -274,8 +274,8 @@ describe Formulary do
"caveats" => "example caveat string", "caveats" => "example caveat string",
"service" => { "service" => {
"run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"], "run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"],
"run_type" => :immediate, "run_type" => "immediate",
"working_dir" => "$HOME", "working_dir" => "/$HOME",
}, },
}.merge(extra_items), }.merge(extra_items),
} }

View File

@ -915,51 +915,33 @@ describe Homebrew::Service do
end end
describe "#serialize" do describe "#serialize" do
context "with a single run command" do let(:serialized_hash) do
let(:serialized_hash) do {
{ environment_variables: {
"environment_variables" => { PATH: "$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:/usr/bin:/bin:/usr/sbin:/sbin",
":PATH" => "$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:/usr/bin:/bin:/usr/sbin:/sbin", },
}, run: [Pathname("$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd"), "test"],
"run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"], run_type: :immediate,
"run_type" => ":immediate", working_dir: "/$HOME",
"working_dir" => "$HOME", cron: "0 0 * * 0",
} sockets: "tcp://0.0.0.0:80",
end }
it "replaces local paths with placeholders" do
f = stub_formula do
service do
run [opt_bin/"beanstalkd", "test"]
environment_variables PATH: std_service_path_env
working_dir Dir.home
end
end
expect(f.service.serialize).to eq(serialized_hash)
end
end end
context "with OS specific run commands" do it "replaces local paths with placeholders" do
let(:serialized_hash) do f = stub_formula do
{ service do
"run" => { run [opt_bin/"beanstalkd", "test"]
":macos" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "macos"], environment_variables PATH: std_service_path_env
":linux" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "linux"], working_dir Dir.home
}, cron "@weekly"
"run_type" => ":immediate", sockets "tcp://0.0.0.0:80"
}
end
it "replaces local paths with placeholders" do
f = stub_formula do
service do
run macos: [opt_bin/"beanstalkd", "macos"], linux: [opt_bin/"beanstalkd", "linux"]
end
end end
expect(f.service.serialize).to eq(serialized_hash)
end end
Formula.generating_hash!
expect(f.service.serialize).to eq(serialized_hash)
Formula.generated_hash!
end end
end end
@ -967,22 +949,24 @@ describe Homebrew::Service do
let(:serialized_hash) do let(:serialized_hash) do
{ {
"environment_variables" => { "environment_variables" => {
":PATH" => "$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:/usr/bin:/bin:/usr/sbin:/sbin", "PATH" => "$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:/usr/bin:/bin:/usr/sbin:/sbin",
}, },
"run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"], "run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"],
"run_type" => ":immediate", "run_type" => "immediate",
"working_dir" => "$HOME", "working_dir" => HOMEBREW_HOME_PLACEHOLDER,
"keep_alive" => { "successful_exit" => false },
} }
end end
let(:deserialized_hash) do let(:deserialized_hash) do
{ {
"environment_variables" => { environment_variables: {
PATH: "#{HOMEBREW_PREFIX}/bin:#{HOMEBREW_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin", PATH: "#{HOMEBREW_PREFIX}/bin:#{HOMEBREW_PREFIX}/sbin:/usr/bin:/bin:/usr/sbin:/sbin",
}, },
"run" => ["#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd", "test"], run: ["#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd", "test"],
"run_type" => :immediate, run_type: :immediate,
"working_dir" => Dir.home, working_dir: Dir.home,
keep_alive: { successful_exit: false },
} }
end end