@@ -149,7 +149,7 @@ func (f *fakeConnector) ExpandVolume(_ context.Context, volumeID string, newSize
149149 return cloud .ErrNotFound
150150}
151151
152- func (f * fakeConnector ) CreateVolumeFromSnapshot (ctx context.Context , zoneID , name , projectID , snapshotID string , sizeInGB int64 ) (* cloud.Volume , error ) {
152+ func (f * fakeConnector ) CreateVolumeFromSnapshot (_ context.Context , zoneID , name , projectID , snapshotID string , sizeInGB int64 ) (* cloud.Volume , error ) {
153153 vol := & cloud.Volume {
154154 ID : "fake-vol-from-snap-" + name ,
155155 Name : name ,
@@ -163,14 +163,31 @@ func (f *fakeConnector) CreateVolumeFromSnapshot(ctx context.Context, zoneID, na
163163}
164164
165165func (f * fakeConnector ) GetSnapshotByID (_ context.Context , snapshotID string ) (* cloud.Snapshot , error ) {
166- return f .snapshot , nil
166+ if f .snapshot != nil && f .snapshot .ID == snapshotID {
167+ return f .snapshot , nil
168+ }
169+ return nil , cloud .ErrNotFound
167170}
168171
169172func (f * fakeConnector ) CreateSnapshot (_ context.Context , volumeID string ) (* cloud.Snapshot , error ) {
170- return f .snapshot , nil
173+ name := "pvc-vol-snap-1" // Always use the same name for test
174+ if snap , ok := f .snapshotsByName [name ]; ok && snap .VolumeID != volumeID {
175+ return nil , errors .New ("snapshot name conflict: already exists for a different source volume" )
176+ }
177+ newSnap := & cloud.Snapshot {
178+ ID : "snap-" + volumeID ,
179+ Name : name ,
180+ DomainID : "fake-domain" ,
181+ ZoneID : zoneID ,
182+ VolumeID : volumeID ,
183+ CreatedAt : "2025-07-07T16:13:06-0700" ,
184+ }
185+ f .snapshotsByName [name ] = newSnap
186+ f .snapshot = newSnap
187+ return newSnap , nil
171188}
172189
173- func (f * fakeConnector ) DeleteSnapshot (_ context.Context , snapshotID string ) error {
190+ func (f * fakeConnector ) DeleteSnapshot (_ context.Context , _ string ) error {
174191 return nil
175192}
176193
0 commit comments