Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix zap tests #21610

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ namespace :test do
ENV['COVERAGE'] = '1'
Rake::Task[:test].invoke
end

desc '[DEBUG] Run test case for `zap`'
task :zap do
ENV['TEST'] = 'test/cask/cli/zap_test'
ENV['TESTOPTS'] =
"-n'/dispatches both uninstall and zap stanzas/' -v"
Rake::Task[:test].invoke
end
end

desc 'Run tests for minitest and RSpec'
Expand Down
49 changes: 25 additions & 24 deletions test/cask/cli/zap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,31 @@
# todo
# Explicit test that both zap and uninstall directives get dispatched.
# The above tests that implicitly.
#
# it "dispatches both uninstall and zap stanzas" do
# with_zap = Hbc.load('with-zap')
#
# shutup do
# Hbc::Installer.new(with_zap).install
# end
#
# with_zap.must_be :installed?
#
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1')
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit'])
#
# Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
# Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
#
# shutup do
# Hbc::CLI::Zap.run('with-zap')
# end
# with_zap.wont_be :installed?
# end

it "dispatches both uninstall and zap stanzas" do
with_zap = Hbc.load('with-zap')

# shutup do
Hbc::Installer.new(with_zap,
command: Hbc::NeverSudoSystemCommand).install
# end

with_zap.must_be :installed?

# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1')
# Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit'])
#
# Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
# Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
#
# shutup do
# Hbc::CLI::Zap.run('with-zap')
# end
# with_zap.wont_be :installed?
end

describe "when no Cask is specified" do
it "raises an exception" do
Expand Down