@@ -121,16 +121,6 @@ var _ = Describe("LocalBackendCleaner", func() {
121
121
Expect (err ).To (Succeed ())
122
122
Expect (report ).To (Equal (mapImageListToCleanupReport (list )))
123
123
})
124
- It ("should return err=nil and full report if opts.DryRun=false calling backend.PruneImages() which returns pruneErr=nil" , func () {
125
- pruneReport := prune.Report {
126
- ItemsDeleted : []string {"one" },
127
- }
128
- backend .EXPECT ().PruneImages (ctx , prune.Options {Filters : filters }).Return (pruneReport , nil )
129
-
130
- report , err := cleaner .pruneImages (ctx , RunGCOptions {})
131
- Expect (err ).To (Succeed ())
132
- Expect (report ).To (Equal (mapPruneReportToCleanupReport (pruneReport )))
133
- })
134
124
It ("should return err=some_err and empty report if opts.DryRun=false calling backend.PruneImages() which returns pruneErr=err" , func () {
135
125
err0 := errors .New ("some_err" )
136
126
backend .EXPECT ().PruneImages (ctx , prune.Options {Filters : filters }).Return (prune.Report {}, err0 )
@@ -146,22 +136,58 @@ var _ = Describe("LocalBackendCleaner", func() {
146
136
Expect (err ).To (Succeed ())
147
137
Expect (report ).To (Equal (newCleanupReport ()))
148
138
})
139
+ It ("should return err=nil and empty report if opts.DryRun=false calling backend.PruneImages() which returns pruneErr=ErrPruneIsAlreadyRunning" , func () {
140
+ backend .EXPECT ().PruneImages (ctx , prune.Options {Filters : filters }).Return (prune.Report {}, container_backend .ErrPruneIsAlreadyRunning )
141
+
142
+ report , err := cleaner .pruneImages (ctx , RunGCOptions {})
143
+ Expect (err ).To (Succeed ())
144
+ Expect (report ).To (Equal (newCleanupReport ()))
145
+ })
146
+ It ("should return err=nil and full report if opts.DryRun=false calling backend.PruneImages() which returns pruneErr=nil" , func () {
147
+ pruneReport := prune.Report {
148
+ ItemsDeleted : []string {"one" },
149
+ }
150
+ backend .EXPECT ().PruneImages (ctx , prune.Options {Filters : filters }).Return (pruneReport , nil )
151
+
152
+ report , err := cleaner .pruneImages (ctx , RunGCOptions {})
153
+ Expect (err ).To (Succeed ())
154
+ Expect (report ).To (Equal (mapPruneReportToCleanupReport (pruneReport )))
155
+ })
149
156
})
150
157
151
158
Describe ("pruneVolumes" , func () {
152
- It ("should return err if opts.DryRun=true" , func () {
153
- _ , err := cleaner .pruneVolumes (ctx , RunGCOptions {
159
+ It ("should return err=errOptionDryRunNotSupported and empty report if opts.DryRun=true" , func () {
160
+ report , err := cleaner .pruneVolumes (ctx , RunGCOptions {
154
161
DryRun : true ,
155
162
})
156
163
Expect (errors .Is (err , errOptionDryRunNotSupported )).To (BeTrue ())
164
+ Expect (report ).To (Equal (newCleanupReport ()))
157
165
})
158
- It ("should call backend.PruneVolumes() if opts.DryRun=false" , func () {
159
- backend .EXPECT ().PruneVolumes (ctx , prune.Options {}).Return (prune.Report {}, nil )
166
+ It ("should return err=nil and empty report if opts.DryRun=false calling backend.PruneVolumes() which returns returns pruneErr=ErrPruneIsAlreadyRunning " , func () {
167
+ backend .EXPECT ().PruneVolumes (ctx , prune.Options {}).Return (prune.Report {}, container_backend . ErrPruneIsAlreadyRunning )
160
168
161
169
report , err := cleaner .pruneVolumes (ctx , RunGCOptions {})
162
170
Expect (err ).To (Succeed ())
163
171
Expect (report ).To (Equal (newCleanupReport ()))
164
172
})
173
+ It ("should return err=some_err and empty report if opts.DryRun=false calling backend.PruneVolumes() which returns returns pruneErr=err" , func () {
174
+ err0 := errors .New ("some_err" )
175
+ backend .EXPECT ().PruneVolumes (ctx , prune.Options {}).Return (prune.Report {}, err0 )
176
+
177
+ report , err := cleaner .pruneVolumes (ctx , RunGCOptions {})
178
+ Expect (err ).To (Equal (err0 ))
179
+ Expect (report ).To (Equal (newCleanupReport ()))
180
+ })
181
+ It ("should return err=nil and full report if opts.DryRun=false calling backend.PruneVolumes() which returns pruneErr=nil" , func () {
182
+ pruneReport := prune.Report {
183
+ ItemsDeleted : []string {"one" },
184
+ }
185
+ backend .EXPECT ().PruneVolumes (ctx , prune.Options {}).Return (pruneReport , nil )
186
+
187
+ report , err := cleaner .pruneVolumes (ctx , RunGCOptions {})
188
+ Expect (err ).To (Succeed ())
189
+ Expect (report ).To (Equal (mapPruneReportToCleanupReport (pruneReport )))
190
+ })
165
191
})
166
192
167
193
Describe ("safeCleanupWerfContainers" , func () {
0 commit comments