@@ -12,22 +12,22 @@ import (
1212)
1313
1414type fakeLightsailClient struct {
15- instanceStateOutput * ls.GetInstanceStateOutput
16- instanceStateByName map [string ]* ls.GetInstanceStateOutput
17- deleteInstanceCalls int
18- createInstancesCalls int
19- createInstancesInput * ls.CreateInstancesInput
20- createInstancesFromSnapshotCalls int
21- createInstancesFromSnapshotInput * ls.CreateInstancesFromSnapshotInput
22- putInstancePublicPortsCalls int
23- getInstanceAccessDetailsOutput * ls.GetInstanceAccessDetailsOutput
24- getInstanceOutput * ls.GetInstanceOutput
25- getInstanceByName map [string ]* types.Instance
26- getInstanceSnapshotsOutput * ls.GetInstanceSnapshotsOutput
27- getInstancesOutput * ls.GetInstancesOutput
28- getRegionsOutput * ls.GetRegionsOutput
29- getBlueprintsOutput * ls.GetBlueprintsOutput
30- getBundlesOutput * ls.GetBundlesOutput
15+ instanceStateOutput * ls.GetInstanceStateOutput
16+ instanceStateByName map [string ]* ls.GetInstanceStateOutput
17+ deleteInstanceCalls int
18+ createInstancesCalls int
19+ createInstancesInput * ls.CreateInstancesInput
20+ createInstancesFromSnapshotCalls int
21+ createInstancesFromSnapshotInput * ls.CreateInstancesFromSnapshotInput
22+ putInstancePublicPortsCalls int
23+ getInstanceAccessDetailsOutput * ls.GetInstanceAccessDetailsOutput
24+ getInstanceOutput * ls.GetInstanceOutput
25+ getInstanceByName map [string ]* types.Instance
26+ getInstanceSnapshotsOutput * ls.GetInstanceSnapshotsOutput
27+ getInstancesOutput * ls.GetInstancesOutput
28+ getRegionsOutput * ls.GetRegionsOutput
29+ getBlueprintsOutput * ls.GetBlueprintsOutput
30+ getBundlesOutput * ls.GetBundlesOutput
3131}
3232
3333func (f * fakeLightsailClient ) GetInstanceState (ctx context.Context , input * ls.GetInstanceStateInput , optFns ... func (* ls.Options )) (* ls.GetInstanceStateOutput , error ) {
@@ -335,6 +335,35 @@ func TestLaunchOrRestoreRestoresSnapshotForCompose(t *testing.T) {
335335 }
336336}
337337
338+ func TestLaunchOrRestoreSkipsSnapshotWhenFreshCreateRetryRequested (t * testing.T ) {
339+ client := & fakeLightsailClient {
340+ getInstanceSnapshotsOutput : & ls.GetInstanceSnapshotsOutput {
341+ InstanceSnapshots : []types.InstanceSnapshot {
342+ {
343+ Name : aws .String ("snap-1" ),
344+ FromInstanceName : aws .String ("demo" ),
345+ State : types .InstanceSnapshotStateAvailable ,
346+ },
347+ },
348+ },
349+ }
350+ p := & Provider {client : client , ctx : context .Background (), region : DefaultRegion }
351+
352+ err := p .launchOrRestore ("demo" , pullpreview.LaunchOptions {
353+ Tags : map [string ]string {"pullpreview_target" : "compose" },
354+ SkipRestore : true ,
355+ })
356+ if err != nil {
357+ t .Fatalf ("launchOrRestore() error: %v" , err )
358+ }
359+ if client .createInstancesCalls != 1 {
360+ t .Fatalf ("expected plain create for skip-restore launch, got %d" , client .createInstancesCalls )
361+ }
362+ if client .createInstancesFromSnapshotCalls != 0 {
363+ t .Fatalf ("did not expect snapshot restore when skip_restore=true, got %d" , client .createInstancesFromSnapshotCalls )
364+ }
365+ }
366+
338367func TestLaunchRecreatesMismatchedDeploymentIdentity (t * testing.T ) {
339368 name := "gh-1-pr-1"
340369 client := & fakeLightsailClient {
0 commit comments