Skip to content
Merged
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
3 changes: 2 additions & 1 deletion lib/linux_admin/distro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class RedHat < Distro
:parted => '/sbin/parted',
:mount => '/bin/mount',
:umount => '/bin/umount',
:shutdown => '/sbin/shutdown'}
:shutdown => '/sbin/shutdown',
:mke2fs => '/sbin/mke2fs'}

def initialize
@id = :redhat
Expand Down
10 changes: 6 additions & 4 deletions lib/linux_admin/partition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def path
"#{disk.path}#{id}"
end

def format_to(filesystem)
run(cmd(:mke2fs),
:params => { '-t' => filesystem, nil => self.path})
@fs_type = filesystem
end

def mount(mount_point=nil)
@mount_point = mount_point
@mount_point =
Expand All @@ -38,9 +44,5 @@ def umount
run(cmd(:umount),
:params => { nil => [@mount_point] })
end

def format_to(fs_type)
#TODO
end
end
end
15 changes: 15 additions & 0 deletions spec/partition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@
end
end

describe "#format_to" do
it "uses mke2fs" do
@partition.should_receive(:run).
with(@partition.cmd(:mke2fs),
:params => { '-t' => 'ext4', nil => '/dev/sda2'})
@partition.format_to('ext4')
end

it "sets fs type" do
@partition.should_receive(:run) # ignore actual formatting cmd
@partition.format_to('ext4')
@partition.fs_type.should == 'ext4'
end
end

describe "#mount" do
it "sets mount point" do
@partition.should_receive(:run) # ignore actual mount cmd
Expand Down