Skip to content

Commit

Permalink
Add test for RemoveHomeContentAction
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 8, 2021
1 parent 23e893b commit e57a89d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
6 changes: 2 additions & 4 deletions test/lib/y2users/linux/delete_user_action_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

it "passes user name as last parameter" do
expect(Yast::Execute).to receive(:on_target!) do |cmd, *args|
expect(Yast::Execute).to receive(:on_target!) do |_cmd, *args|
expect(args.last).to eq "test"
end

Expand All @@ -34,7 +34,7 @@
let(:commit_config) { Y2Users::CommitConfig.new.tap { |c| c.remove_home = true } }

it "passes --remove parameter" do
expect(Yast::Execute).to receive(:on_target!) do |cmd, *args|
expect(Yast::Execute).to receive(:on_target!) do |_cmd, *args|
expect(args).to include "--remove"
end

Expand All @@ -43,5 +43,3 @@
end
end
end


40 changes: 40 additions & 0 deletions test/lib/y2users/linux/remove_home_content_action_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require_relative "../test_helper"

require "date"
require "y2users/user"
require "y2users/linux/remove_home_content_action"
require "y2users/commit_config"

describe Y2Users::Linux::RemoveHomeContentAction do
subject(:action) { described_class.new(user, commit_config) }
let(:user) { Y2Users::User.new("test") }
let(:commit_config) { nil }

before do
allow(Yast::Execute).to receive(:on_target!)
end

describe "#perform" do

it "removes content with find -mindepth 1 -delete" do
expect(Yast::Execute).to receive(:on_target!) do |cmd, *args|
expect(cmd).to eq "/usr/bin/find"
expect(args).to include "-mindepth"
expect(args).to include "1"
expect(args).to include "-delete"
end

action.perform
end

it "passes user home as parameter" do
user.home.path = "/tmp/home"

expect(Yast::Execute).to receive(:on_target!) do |_cmd, *args|
expect(args).to include "/tmp/home"
end

action.perform
end
end
end

0 comments on commit e57a89d

Please sign in to comment.