@@ -6,12 +6,10 @@ import { Image, ImageMap, getRange } from '../../src/imageAnalysis/collector';
66
77describe ( 'Image Analysis Collector tests' , ( ) => {
88
9- // Mock image collection
10- let reqImages : Image [ ] = [
11- new Image ( { value : 'alpine' , position : { line : 1 , column : 0 } } , 'FROM --platform=linux/amd64 alpine as a' ) ,
12- new Image ( { value : 'alpine:latest' , position : { line : 2 , column : 0 } } , 'FROM --platform=linux/amd64 alpine:latest AS a' ) ,
9+ // Mock image collection, we can't test unpinned images here as they will change over time, resulting in tests that always need updating.
10+ const reqImages : Image [ ] = [
11+ new Image ( { value : 'alpine:3.21.3' , position : { line : 2 , column : 0 } } , 'FROM --platform=linux/amd64 alpine:3.21.3 AS a' ) ,
1312 new Image ( { value : 'alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b' , position : { line : 3 , column : 0 } } , 'FROM --platform=linux/amd64 alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b As a' ) ,
14- new Image ( { value : 'alpine' , position : { line : 4 , column : 0 } } , 'FROM --platform=linux/amd64 alpine as a' ) ,
1513 ] ;
1614 reqImages . forEach ( image => image . platform = 'linux/amd64' ) ;
1715
@@ -20,9 +18,8 @@ describe('Image Analysis Collector tests', () => {
2018 const imageMap = new ImageMap ( reqImages ) ;
2119
2220 expect ( Object . fromEntries ( imageMap . mapper ) ) . to . eql ( {
23- 'alpine' : [ reqImages [ 0 ] , reqImages [ 3 ] ] ,
24- 'alpine:latest' : [ reqImages [ 1 ] ] ,
25- 'alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b' : [ reqImages [ 2 ] ]
21+ 'pkg:oci/alpine@sha256:1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474?arch=amd64&os=linux&tag=3.21.3' : [ reqImages [ 0 ] ] ,
22+ 'pkg:oci/alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b?arch=amd64&os=linux' : [ reqImages [ 1 ] ]
2623 } ) ;
2724 } ) ;
2825
@@ -37,39 +34,25 @@ describe('Image Analysis Collector tests', () => {
3734
3835 const imageMap = new ImageMap ( reqImages ) ;
3936
40- // The image names from the response always iclude 'latest' tag if no tag nor digest is provided
41- expect ( JSON . stringify ( imageMap . get ( 'alpine:latest' ) ) ) . to . eq ( JSON . stringify ( [ reqImages [ 1 ] , reqImages [ 0 ] , reqImages [ 3 ] ] ) ) ;
42- expect ( JSON . stringify ( imageMap . get ( 'alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b' ) ) ) . to . eq ( JSON . stringify ( [ reqImages [ 2 ] ] ) ) ;
37+ expect ( JSON . stringify ( imageMap . get ( 'pkg:oci/alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b?arch=amd64&os=linux' ) ) ) . to . eq ( JSON . stringify ( [ reqImages [ 1 ] ] ) ) ;
4338 } ) ;
4439
4540 it ( 'should return image range' , async ( ) => {
46-
4741 expect ( getRange ( reqImages [ 0 ] ) ) . to . eql (
48- {
49- start : { line : 0 , character : 0 } ,
50- end : { line : 0 , character : 39 }
51- }
52- ) ;
53-
54- expect ( getRange ( reqImages [ 1 ] ) ) . to . eql (
5542 {
5643 start : { line : 1 , character : 0 } ,
5744 end : { line : 1 , character : 46 }
5845 }
5946 ) ;
6047
61- expect ( getRange ( reqImages [ 2 ] ) ) . to . eql (
48+ expect ( getRange ( reqImages [ 1 ] ) ) . to . eql (
6249 {
6350 start : { line : 2 , character : 0 } ,
6451 end : { line : 2 , character : 111 }
6552 }
6653 ) ;
67-
68- expect ( getRange ( reqImages [ 3 ] ) ) . to . eql (
69- {
70- start : { line : 3 , character : 0 } ,
71- end : { line : 3 , character : 39 }
72- }
73- ) ;
7454 } ) ;
75- } )
55+ } ) . beforeAll ( ( ) => {
56+ // https://github.com/containers/skopeo/issues/1654
57+ process . env [ 'EXHORT_SKOPEO_CONFIG_PATH' ] = './auth.json' ;
58+ } ) ;
0 commit comments