@@ -139,7 +139,7 @@ func (f *fakeConnector) ExpandVolume(_ context.Context, volumeID string, newSize
139139 return cloud .ErrNotFound
140140}
141141
142- func (f * fakeConnector ) CreateVolumeFromSnapshot (_ context.Context , zoneID , name , _ , snapshotID string , sizeInGB int64 ) (* cloud.Volume , error ) {
142+ func (f * fakeConnector ) CreateVolumeFromSnapshot (_ context.Context , zoneID , name , _ , _ string , sizeInGB int64 ) (* cloud.Volume , error ) {
143143 vol := & cloud.Volume {
144144 ID : "fake-vol-from-snap-" + name ,
145145 Name : name ,
@@ -149,6 +149,7 @@ func (f *fakeConnector) CreateVolumeFromSnapshot(_ context.Context, zoneID, name
149149 }
150150 f .volumesByID [vol .ID ] = * vol
151151 f .volumesByName [vol .Name ] = * vol
152+
152153 return vol , nil
153154}
154155
@@ -161,6 +162,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
161162 // Allow multiple snapshots with the same name for the same volume
162163 continue
163164 }
165+
164166 // Name conflict: same name, different volume
165167 return nil , cloud .ErrAlreadyExists
166168 }
@@ -175,6 +177,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
175177 }
176178 f .snapshotsByID [newSnap .ID ] = newSnap
177179 f .snapshotsByName [name ] = append (f .snapshotsByName [name ], newSnap )
180+
178181 return newSnap , nil
179182}
180183
@@ -183,6 +186,7 @@ func (f *fakeConnector) GetSnapshotByID(_ context.Context, snapshotID string) (*
183186 if ok {
184187 return snap , nil
185188 }
189+
186190 return nil , cloud .ErrNotFound
187191}
188192
@@ -194,6 +198,7 @@ func (f *fakeConnector) GetSnapshotByName(_ context.Context, name string) (*clou
194198 if ok && len (snaps ) > 0 {
195199 return snaps [0 ], nil // Return the first for compatibility
196200 }
201+
197202 return nil , cloud .ErrNotFound
198203}
199204
@@ -204,6 +209,7 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
204209 if snap , ok := f .snapshotsByID [snapshotID ]; ok {
205210 result = append (result , snap )
206211 }
212+
207213 return result , nil
208214 }
209215 if volumeID != "" {
@@ -212,11 +218,13 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
212218 result = append (result , snap )
213219 }
214220 }
221+
215222 return result , nil
216223 }
217224 for _ , snap := range f .snapshotsByID {
218225 result = append (result , snap )
219226 }
227+
220228 return result , nil
221229}
222230
@@ -225,9 +233,9 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
225233 if ! ok {
226234 return cloud .ErrNotFound
227235 }
228- // Remove from snapshotsByID
236+
229237 delete (f .snapshotsByID , snapshotID )
230- // Remove from snapshotsByName
238+
231239 name := snap .Name
232240 snaps := f .snapshotsByName [name ]
233241 for i , s := range snaps {
@@ -236,5 +244,6 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
236244 break
237245 }
238246 }
247+
239248 return nil
240249}
0 commit comments