Skip to content

Commit

Permalink
rm_user, expect_no_user
Browse files Browse the repository at this point in the history
  • Loading branch information
danielparks committed Feb 15, 2024
1 parent c799ac0 commit c6ccbd9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
26 changes: 4 additions & 22 deletions spec/acceptance/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@

context "remove" do
it 'can remove itself after the user was deleted' do
expect(user('rustup_test')).not_to exist
expect(file('/home/rustup_test')).not_to exist
expect_no_user('rustup_test')

apply_manifest(<<~'END', catch_failures: true)
user { 'rustup_test':
Expand Down Expand Up @@ -423,19 +422,11 @@
expect(file('/home/rustup_test/.bashrc').content).to eq %(# .bashrc\n)

# Clean up
apply_manifest(<<~'END', catch_failures: true)
user { 'rustup_test':
ensure => absent,
}
file { '/home/rustup_test':
ensure => absent,
force => true,
}
END
rm_user('rustup_test')
end

it 'can remove itself after the user was deleted (with custom cargo_home)' do
rm_user('rustup_test')
expect(user('rustup_test')).not_to exist
expect(file('/home/rustup_test')).not_to exist

Expand Down Expand Up @@ -502,16 +493,7 @@
expect(file('/home/rustup_test/.bashrc').content).to eq %(# .bashrc\n)

# Clean up
apply_manifest(<<~'END', catch_failures: true)
user { 'rustup_test':
ensure => absent,
}
file { '/home/rustup_test':
ensure => absent,
force => true,
}
END
rm_user('rustup_test')
end
end
end
20 changes: 20 additions & 0 deletions spec/spec_helper_acceptance_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ def command_global_rustup(params)
def command_as_user(cmd)
command("sudo -iu user #{cmd}")
end

def expect_no_user(name)
it "user #{name}" do
expect(user(name)).not_to exist
expect(file("/home/#{name}")).not_to exist
end
end

def rm_user(name)
apply_manifest(<<~'END', catch_failures: true)
user { 'rustup_test':
ensure => absent,
}
file { '/home/rustup_test':
ensure => absent,
force => true,
}
END
end

0 comments on commit c6ccbd9

Please sign in to comment.