@@ -130,35 +130,7 @@ public async Task ApiEndToEndWithLocalLoad()
130
130
[ DockerAvailableFact ]
131
131
public async Task ApiEndToEndWithArchiveWritingAndLoad ( )
132
132
{
133
- var archiveFile = Path . Combine ( TestSettings . TestArtifactsDirectory ,
134
- nameof ( ApiEndToEndWithArchiveWritingAndLoad ) , "app.tar.gz" ) ;
135
-
136
- // Build the image
137
- ( BuiltImage builtImage , SourceImageReference sourceReference , DestinationImageReference destinationReference ) =
138
- await BuildDockerImageWithArciveDestinationAsync ( archiveFile , [ "latest" , "1.0" ] , nameof ( ApiEndToEndWithArchiveWritingAndLoad ) ) ;
139
-
140
- // Write the image to disk
141
- await destinationReference . LocalRegistry ! . LoadAsync ( builtImage , sourceReference , destinationReference , default ) . ConfigureAwait ( false ) ;
142
-
143
- Assert . True ( File . Exists ( archiveFile ) , $ "File.Exists({ archiveFile } )") ;
144
-
145
- // Load the archive
146
- ContainerCli . LoadCommand ( _testOutput , "--input" , archiveFile )
147
- . Execute ( )
148
- . Should ( ) . Pass ( ) ;
149
-
150
- // Run the image
151
- foreach ( string tag in destinationReference . Tags )
152
- {
153
- ContainerCli . RunCommand ( _testOutput , "--rm" , "--tty" , $ "{ NewImageName ( ) } :{ tag } ")
154
- . Execute ( )
155
- . Should ( ) . Pass ( ) ;
156
- }
157
- }
158
-
159
- private async Task < ( BuiltImage image , SourceImageReference sourceReference , DestinationImageReference destinationReference ) > BuildDockerImageWithArciveDestinationAsync ( string archiveFile , string [ ] tags , string testName )
160
- {
161
- ILogger logger = _loggerFactory . CreateLogger ( testName ) ;
133
+ ILogger logger = _loggerFactory . CreateLogger ( nameof ( ApiEndToEndWithArchiveWritingAndLoad ) ) ;
162
134
string publishDirectory = BuildLocalApp ( tfm : "net8.0" ) ;
163
135
164
136
// Build the image
@@ -182,10 +154,27 @@ public async Task ApiEndToEndWithArchiveWritingAndLoad()
182
154
BuiltImage builtImage = imageBuilder . Build ( ) ;
183
155
184
156
// Write the image to disk
157
+ var archiveFile = Path . Combine ( TestSettings . TestArtifactsDirectory ,
158
+ nameof ( ApiEndToEndWithArchiveWritingAndLoad ) , "app.tar.gz" ) ;
185
159
var sourceReference = new SourceImageReference ( registry , DockerRegistryManager . RuntimeBaseImage , DockerRegistryManager . Net7ImageTag ) ;
186
- var destinationReference = new DestinationImageReference ( new ArchiveFileRegistry ( archiveFile ) , NewImageName ( ) , tags ) ;
160
+ var destinationReference = new DestinationImageReference ( new ArchiveFileRegistry ( archiveFile ) , NewImageName ( ) , new [ ] { "latest" , "1.0" } ) ;
187
161
188
- return ( builtImage , sourceReference , destinationReference ) ;
162
+ await destinationReference . LocalRegistry ! . LoadAsync ( builtImage , sourceReference , destinationReference , default ) . ConfigureAwait ( false ) ;
163
+
164
+ Assert . True ( File . Exists ( archiveFile ) , $ "File.Exists({ archiveFile } )") ;
165
+
166
+ // Load the archive
167
+ ContainerCli . LoadCommand ( _testOutput , "--input" , archiveFile )
168
+ . Execute ( )
169
+ . Should ( ) . Pass ( ) ;
170
+
171
+ // Run the image
172
+ foreach ( string tag in destinationReference . Tags )
173
+ {
174
+ ContainerCli . RunCommand ( _testOutput , "--rm" , "--tty" , $ "{ NewImageName ( ) } :{ tag } ")
175
+ . Execute ( )
176
+ . Should ( ) . Pass ( ) ;
177
+ }
189
178
}
190
179
191
180
[ DockerAvailableFact ]
@@ -214,6 +203,28 @@ public async Task TarballsHaveCorrectStructure()
214
203
CheckOciTarballStructure ( archiveFile ) ;
215
204
}
216
205
206
+ private async Task < ( BuiltImage image , SourceImageReference sourceReference , DestinationImageReference destinationReference ) > BuildDockerImageWithArciveDestinationAsync ( string archiveFile , string [ ] tags , string testName )
207
+ {
208
+ ILogger logger = _loggerFactory . CreateLogger ( testName ) ;
209
+ Registry registry = new ( DockerRegistryManager . LocalRegistry , logger , RegistryMode . Push ) ;
210
+
211
+ ImageBuilder imageBuilder = await registry . GetImageManifestAsync (
212
+ DockerRegistryManager . RuntimeBaseImage ,
213
+ DockerRegistryManager . Net8ImageTag ,
214
+ "linux-x64" ,
215
+ ToolsetUtils . RidGraphManifestPicker ,
216
+ cancellationToken : default ) . ConfigureAwait ( false ) ;
217
+ Assert . NotNull ( imageBuilder ) ;
218
+
219
+ BuiltImage builtImage = imageBuilder . Build ( ) ;
220
+
221
+ // Write the image to disk
222
+ var sourceReference = new SourceImageReference ( registry , DockerRegistryManager . RuntimeBaseImage , DockerRegistryManager . Net7ImageTag ) ;
223
+ var destinationReference = new DestinationImageReference ( new ArchiveFileRegistry ( archiveFile ) , NewImageName ( ) , tags ) ;
224
+
225
+ return ( builtImage , sourceReference , destinationReference ) ;
226
+ }
227
+
217
228
private BuiltImage ConvertToOciImage ( BuiltImage builtImage )
218
229
{
219
230
// Convert the image to an OCI image
0 commit comments