@@ -106,6 +106,52 @@ func TestLoadLocal_ImportError(t *testing.T) {
106106 assert .Contains (t , err .Error (), "incompatible version" )
107107}
108108
109+ func TestLoadLocal_IncompatibleSnapshot_StructuredError (t * testing.T ) {
110+ t .Parallel ()
111+ src := writeSnapshotFile (t , "ZIP_DATA" )
112+ importErr := fmt .Errorf ("%w: Pod state is incompatible with the current LocalStack version" , snapshot .ErrIncompatibleSnapshot )
113+ client := mockLocalClientReturning (t , importErr )
114+ sink , getEvents := captureEvents (t )
115+
116+ err := snapshot .LoadLocal (context .Background (), healthyRunningMock (t ), awsContainers , client , "" , src , "" , nopStarter , sink )
117+ require .Error (t , err )
118+ assert .True (t , output .IsSilent (err ), "incompatible-snapshot error should be silent so it isn't double-rendered" )
119+
120+ var errEvent * output.ErrorEvent
121+ for _ , e := range getEvents () {
122+ if ev , ok := e .(output.ErrorEvent ); ok {
123+ errEvent = & ev
124+ }
125+ }
126+ require .NotNil (t , errEvent , "a structured ErrorEvent should have been emitted" )
127+ assert .Equal (t , "Could not load snapshot" , errEvent .Title )
128+ assert .Equal (t , "Snapshot is incompatible with the running LocalStack version" , errEvent .Summary )
129+ }
130+
131+ func TestLoadPod_IncompatibleSnapshot_StructuredError (t * testing.T ) {
132+ t .Parallel ()
133+ ctrl := gomock .NewController (t )
134+ loader := NewMockPodLoader (ctrl )
135+ loadErr := fmt .Errorf ("%w: Pod state is incompatible with the current LocalStack version" , snapshot .ErrIncompatibleSnapshot )
136+ loader .EXPECT ().LoadPodSnapshot (gomock .Any (), gomock .Any (), "my-baseline" , "test-token" , gomock .Any ()).
137+ Return (nil , loadErr )
138+
139+ sink , getEvents := captureEvents (t )
140+ err := snapshot .LoadPod (context .Background (), healthyRunningMock (t ), awsContainers , loader , "" , "my-baseline" , "test-token" , "" , nopStarter , sink )
141+ require .Error (t , err )
142+ assert .True (t , output .IsSilent (err ))
143+
144+ var errEvent * output.ErrorEvent
145+ for _ , e := range getEvents () {
146+ if ev , ok := e .(output.ErrorEvent ); ok {
147+ errEvent = & ev
148+ }
149+ }
150+ require .NotNil (t , errEvent , "a structured ErrorEvent should have been emitted" )
151+ assert .Equal (t , "Could not load snapshot" , errEvent .Title )
152+ assert .Equal (t , "Snapshot is incompatible with the running LocalStack version" , errEvent .Summary )
153+ }
154+
109155func TestLoadLocal_FileNotFound (t * testing.T ) {
110156 t .Parallel ()
111157 ctrl := gomock .NewController (t )
0 commit comments