Skip to content

Commit

Permalink
rename to OrphanDisk
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatarupa Nandi committed May 11, 2017
1 parent f0ece5f commit 617276e
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 232 deletions.
2 changes: 1 addition & 1 deletion bin/gen-fakes
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ counterfeiter director ReleaseArchive
counterfeiter director Stemcell
counterfeiter director StemcellArchive
counterfeiter director Task
counterfeiter director OrphanedDisk
counterfeiter director OrphanDisk
counterfeiter director FileReporter
counterfeiter director TaskReporter
counterfeiter director Event
Expand Down
2 changes: 1 addition & 1 deletion cmd/delete_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (c DeleteDiskCmd) Run(opts DeleteDiskOpts) error {
return err
}

disk, err := c.director.FindOrphanedDisk(opts.Args.CID)
disk, err := c.director.FindOrphanDisk(opts.Args.CID)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/delete_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ var _ = Describe("DeleteDiskCmd", func() {
act := func() error { return command.Run(opts) }

It("deletes orphaned disk", func() {
disk := &fakedir.FakeOrphanedDisk{}
director.FindOrphanedDiskReturns(disk, nil)
disk := &fakedir.FakeOrphanDisk{}
director.FindOrphanDiskReturns(disk, nil)

err := act()
Expect(err).ToNot(HaveOccurred())

Expect(director.FindOrphanedDiskArgsForCall(0)).To(Equal("disk-cid"))
Expect(director.FindOrphanDiskArgsForCall(0)).To(Equal("disk-cid"))
Expect(disk.DeleteCallCount()).To(Equal(1))
})

It("returns error if deleting disk failed", func() {
disk := &fakedir.FakeOrphanedDisk{}
director.FindOrphanedDiskReturns(disk, nil)
disk := &fakedir.FakeOrphanDisk{}
director.FindOrphanDiskReturns(disk, nil)

disk.DeleteReturns(errors.New("fake-err"))

Expand All @@ -60,8 +60,8 @@ var _ = Describe("DeleteDiskCmd", func() {
})

It("does not delete disk if confirmation is rejected", func() {
disk := &fakedir.FakeOrphanedDisk{}
director.FindOrphanedDiskReturns(disk, nil)
disk := &fakedir.FakeOrphanDisk{}
director.FindOrphanDiskReturns(disk, nil)

ui.AskedConfirmationErr = errors.New("stop")

Expand All @@ -73,7 +73,7 @@ var _ = Describe("DeleteDiskCmd", func() {
})

It("returns error if finding disk failed", func() {
director.FindOrphanedDiskReturns(nil, errors.New("fake-err"))
director.FindOrphanDiskReturns(nil, errors.New("fake-err"))

err := act()
Expect(err).To(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion cmd/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c DisksCmd) Run(opts DisksOpts) error {
return errors.New("Only --orphaned is supported")
}

disks, err := c.director.OrphanedDisks()
disks, err := c.director.OrphanDisks()
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ var _ = Describe("DisksCmd", func() {
})

It("lists disks", func() {
disks := []boshdir.OrphanedDisk{
&fakedir.FakeOrphanedDisk{
disks := []boshdir.OrphanDisk{
&fakedir.FakeOrphanDisk{
CIDStub: func() string { return "cid" },
SizeStub: func() uint64 { return 100 },

Expand All @@ -63,7 +63,7 @@ var _ = Describe("DisksCmd", func() {
},
}

director.OrphanedDisksReturns(disks, nil)
director.OrphanDisksReturns(disks, nil)

err := act()
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -96,7 +96,7 @@ var _ = Describe("DisksCmd", func() {
})

It("returns error if orphaned disks cannot be retrieved", func() {
director.OrphanedDisksReturns(nil, errors.New("fake-err"))
director.OrphanDisksReturns(nil, errors.New("fake-err"))

err := act()
Expect(err).To(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion cmd/orphan_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ func (c OrphanDiskCmd) Run(opts OrphanDiskOpts) error {
return err
}

return c.director.Orphan(opts.Args.CID)
return c.director.OrphanDisk(opts.Args.CID)
}
11 changes: 4 additions & 7 deletions cmd/orphan_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,29 @@ var _ = Describe("OrphanDiskCmd", func() {
act := func() error { return command.Run(opts) }

It("orphans disk", func() {

err := act()
Expect(err).ToNot(HaveOccurred())

Expect(director.OrphanArgsForCall(0)).To(Equal("disk-cid"))
Expect(director.OrphanCallCount()).To(Equal(1))
Expect(director.OrphanDiskArgsForCall(0)).To(Equal("disk-cid"))
Expect(director.OrphanDiskCallCount()).To(Equal(1))
})

It("returns error if orphaning disk failed", func() {

director.OrphanReturns(errors.New("fake-err"))
director.OrphanDiskReturns(errors.New("fake-err"))

err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-err"))
})

It("does not orphan disk if confirmation is rejected", func() {

ui.AskedConfirmationErr = errors.New("stop")

err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("stop"))

Expect(director.OrphanCallCount()).To(Equal(0))
Expect(director.OrphanDiskCallCount()).To(Equal(0))
})
})
})
150 changes: 75 additions & 75 deletions director/directorfakes/fake_director.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,28 @@ type FakeDirector struct {
updateRuntimeConfigReturns struct {
result1 error
}
FindOrphanedDiskStub func(string) (director.OrphanedDisk, error)
findOrphanedDiskMutex sync.RWMutex
findOrphanedDiskArgsForCall []struct {
FindOrphanDiskStub func(string) (director.OrphanDisk, error)
findOrphanDiskMutex sync.RWMutex
findOrphanDiskArgsForCall []struct {
arg1 string
}
findOrphanedDiskReturns struct {
result1 director.OrphanedDisk
findOrphanDiskReturns struct {
result1 director.OrphanDisk
result2 error
}
OrphanedDisksStub func() ([]director.OrphanedDisk, error)
orphanedDisksMutex sync.RWMutex
orphanedDisksArgsForCall []struct{}
orphanedDisksReturns struct {
result1 []director.OrphanedDisk
OrphanDisksStub func() ([]director.OrphanDisk, error)
orphanDisksMutex sync.RWMutex
orphanDisksArgsForCall []struct{}
orphanDisksReturns struct {
result1 []director.OrphanDisk
result2 error
}
OrphanStub func(string) error
orphanMutex sync.RWMutex
orphanArgsForCall []struct {
OrphanDiskStub func(string) error
orphanDiskMutex sync.RWMutex
orphanDiskArgsForCall []struct {
arg1 string
}
orphanReturns struct {
orphanDiskReturns struct {
result1 error
}
EnableResurrectionStub func(bool) error
Expand Down Expand Up @@ -1314,92 +1314,92 @@ func (fake *FakeDirector) UpdateRuntimeConfigReturns(result1 error) {
}{result1}
}

func (fake *FakeDirector) FindOrphanedDisk(arg1 string) (director.OrphanedDisk, error) {
fake.findOrphanedDiskMutex.Lock()
fake.findOrphanedDiskArgsForCall = append(fake.findOrphanedDiskArgsForCall, struct {
func (fake *FakeDirector) FindOrphanDisk(arg1 string) (director.OrphanDisk, error) {
fake.findOrphanDiskMutex.Lock()
fake.findOrphanDiskArgsForCall = append(fake.findOrphanDiskArgsForCall, struct {
arg1 string
}{arg1})
fake.recordInvocation("FindOrphanedDisk", []interface{}{arg1})
fake.findOrphanedDiskMutex.Unlock()
if fake.FindOrphanedDiskStub != nil {
return fake.FindOrphanedDiskStub(arg1)
fake.recordInvocation("FindOrphanDisk", []interface{}{arg1})
fake.findOrphanDiskMutex.Unlock()
if fake.FindOrphanDiskStub != nil {
return fake.FindOrphanDiskStub(arg1)
}
return fake.findOrphanedDiskReturns.result1, fake.findOrphanedDiskReturns.result2
return fake.findOrphanDiskReturns.result1, fake.findOrphanDiskReturns.result2
}

func (fake *FakeDirector) FindOrphanedDiskCallCount() int {
fake.findOrphanedDiskMutex.RLock()
defer fake.findOrphanedDiskMutex.RUnlock()
return len(fake.findOrphanedDiskArgsForCall)
func (fake *FakeDirector) FindOrphanDiskCallCount() int {
fake.findOrphanDiskMutex.RLock()
defer fake.findOrphanDiskMutex.RUnlock()
return len(fake.findOrphanDiskArgsForCall)
}

func (fake *FakeDirector) FindOrphanedDiskArgsForCall(i int) string {
fake.findOrphanedDiskMutex.RLock()
defer fake.findOrphanedDiskMutex.RUnlock()
return fake.findOrphanedDiskArgsForCall[i].arg1
func (fake *FakeDirector) FindOrphanDiskArgsForCall(i int) string {
fake.findOrphanDiskMutex.RLock()
defer fake.findOrphanDiskMutex.RUnlock()
return fake.findOrphanDiskArgsForCall[i].arg1
}

func (fake *FakeDirector) FindOrphanedDiskReturns(result1 director.OrphanedDisk, result2 error) {
fake.FindOrphanedDiskStub = nil
fake.findOrphanedDiskReturns = struct {
result1 director.OrphanedDisk
func (fake *FakeDirector) FindOrphanDiskReturns(result1 director.OrphanDisk, result2 error) {
fake.FindOrphanDiskStub = nil
fake.findOrphanDiskReturns = struct {
result1 director.OrphanDisk
result2 error
}{result1, result2}
}

func (fake *FakeDirector) OrphanedDisks() ([]director.OrphanedDisk, error) {
fake.orphanedDisksMutex.Lock()
fake.orphanedDisksArgsForCall = append(fake.orphanedDisksArgsForCall, struct{}{})
fake.recordInvocation("OrphanedDisks", []interface{}{})
fake.orphanedDisksMutex.Unlock()
if fake.OrphanedDisksStub != nil {
return fake.OrphanedDisksStub()
func (fake *FakeDirector) OrphanDisks() ([]director.OrphanDisk, error) {
fake.orphanDisksMutex.Lock()
fake.orphanDisksArgsForCall = append(fake.orphanDisksArgsForCall, struct{}{})
fake.recordInvocation("OrphanDisks", []interface{}{})
fake.orphanDisksMutex.Unlock()
if fake.OrphanDisksStub != nil {
return fake.OrphanDisksStub()
}
return fake.orphanedDisksReturns.result1, fake.orphanedDisksReturns.result2
return fake.orphanDisksReturns.result1, fake.orphanDisksReturns.result2
}

func (fake *FakeDirector) OrphanedDisksCallCount() int {
fake.orphanedDisksMutex.RLock()
defer fake.orphanedDisksMutex.RUnlock()
return len(fake.orphanedDisksArgsForCall)
func (fake *FakeDirector) OrphanDisksCallCount() int {
fake.orphanDisksMutex.RLock()
defer fake.orphanDisksMutex.RUnlock()
return len(fake.orphanDisksArgsForCall)
}

func (fake *FakeDirector) OrphanedDisksReturns(result1 []director.OrphanedDisk, result2 error) {
fake.OrphanedDisksStub = nil
fake.orphanedDisksReturns = struct {
result1 []director.OrphanedDisk
func (fake *FakeDirector) OrphanDisksReturns(result1 []director.OrphanDisk, result2 error) {
fake.OrphanDisksStub = nil
fake.orphanDisksReturns = struct {
result1 []director.OrphanDisk
result2 error
}{result1, result2}
}

func (fake *FakeDirector) Orphan(arg1 string) error {
fake.orphanMutex.Lock()
fake.orphanArgsForCall = append(fake.orphanArgsForCall, struct {
func (fake *FakeDirector) OrphanDisk(arg1 string) error {
fake.orphanDiskMutex.Lock()
fake.orphanDiskArgsForCall = append(fake.orphanDiskArgsForCall, struct {
arg1 string
}{arg1})
fake.recordInvocation("Orphan", []interface{}{arg1})
fake.orphanMutex.Unlock()
if fake.OrphanStub != nil {
return fake.OrphanStub(arg1)
fake.recordInvocation("OrphanDisk", []interface{}{arg1})
fake.orphanDiskMutex.Unlock()
if fake.OrphanDiskStub != nil {
return fake.OrphanDiskStub(arg1)
}
return fake.orphanReturns.result1
return fake.orphanDiskReturns.result1
}

func (fake *FakeDirector) OrphanCallCount() int {
fake.orphanMutex.RLock()
defer fake.orphanMutex.RUnlock()
return len(fake.orphanArgsForCall)
func (fake *FakeDirector) OrphanDiskCallCount() int {
fake.orphanDiskMutex.RLock()
defer fake.orphanDiskMutex.RUnlock()
return len(fake.orphanDiskArgsForCall)
}

func (fake *FakeDirector) OrphanArgsForCall(i int) string {
fake.orphanMutex.RLock()
defer fake.orphanMutex.RUnlock()
return fake.orphanArgsForCall[i].arg1
func (fake *FakeDirector) OrphanDiskArgsForCall(i int) string {
fake.orphanDiskMutex.RLock()
defer fake.orphanDiskMutex.RUnlock()
return fake.orphanDiskArgsForCall[i].arg1
}

func (fake *FakeDirector) OrphanReturns(result1 error) {
fake.OrphanStub = nil
fake.orphanReturns = struct {
func (fake *FakeDirector) OrphanDiskReturns(result1 error) {
fake.OrphanDiskStub = nil
fake.orphanDiskReturns = struct {
result1 error
}{result1}
}
Expand Down Expand Up @@ -1566,12 +1566,12 @@ func (fake *FakeDirector) Invocations() map[string][][]interface{} {
defer fake.latestRuntimeConfigMutex.RUnlock()
fake.updateRuntimeConfigMutex.RLock()
defer fake.updateRuntimeConfigMutex.RUnlock()
fake.findOrphanedDiskMutex.RLock()
defer fake.findOrphanedDiskMutex.RUnlock()
fake.orphanedDisksMutex.RLock()
defer fake.orphanedDisksMutex.RUnlock()
fake.orphanMutex.RLock()
defer fake.orphanMutex.RUnlock()
fake.findOrphanDiskMutex.RLock()
defer fake.findOrphanDiskMutex.RUnlock()
fake.orphanDisksMutex.RLock()
defer fake.orphanDisksMutex.RUnlock()
fake.orphanDiskMutex.RLock()
defer fake.orphanDiskMutex.RUnlock()
fake.enableResurrectionMutex.RLock()
defer fake.enableResurrectionMutex.RUnlock()
fake.cleanUpMutex.RLock()
Expand Down
Loading

0 comments on commit 617276e

Please sign in to comment.