@@ -325,94 +325,3 @@ resources:
325325 })
326326 }
327327}
328-
329- func Test_Add_And_Transfer_Access_Type_Casing (t * testing.T ) {
330- tests := []struct {
331- name string
332- accessType string
333- expectedAccess string
334- }{
335- {
336- name : "helm/v1 access lowercase" ,
337- accessType : "helm/v1" ,
338- expectedAccess : "helm/v1" ,
339- },
340- {
341- name : "Helm/v1 access upper camel case" ,
342- accessType : "Helm/v1" ,
343- expectedAccess : "Helm/v1" ,
344- },
345- }
346-
347- for _ , tc := range tests {
348- t .Run (tc .name , func (t * testing.T ) {
349- r := require .New (t )
350- tmp := t .TempDir ()
351-
352- constructorYAML := fmt .Sprintf (`
353- name: ocm.software/test-access-casing
354- version: 1.0.0
355- provider:
356- name: ocm.software
357- resources:
358- - name: my-chart
359- version: 1.0.0
360- type: helmChart
361- access:
362- type: %s
363- helmRepository: https://charts.example.com
364- helmChart: my-chart:1.0.0
365- ` , tc .accessType )
366-
367- constructorPath := filepath .Join (tmp , "constructor.yaml" )
368- r .NoError (os .WriteFile (constructorPath , []byte (constructorYAML ), 0o600 ))
369-
370- // Step 1: add cv (access types don't resolve at add time)
371- sourceArchive := filepath .Join (tmp , "source-archive" )
372- logs := test .NewJSONLogReader ()
373- _ , err := test .OCM (t , test .WithArgs ("add" , "cv" ,
374- "--constructor" , constructorPath ,
375- "--repository" , sourceArchive ,
376- ), test .WithErrorOutput (logs ))
377- r .NoError (err , "add cv failed for access type %s" , tc .accessType )
378-
379- // Verify source CTF
380- sourceFS , err := filesystem .NewFS (sourceArchive , os .O_RDONLY )
381- r .NoError (err )
382- sourceRepo , err := oci .NewRepository (ocictf .WithCTF (ocictf .NewFromCTF (ctf .NewFileSystemCTF (sourceFS ))))
383- r .NoError (err )
384-
385- desc , err := sourceRepo .GetComponentVersion (t .Context (), "ocm.software/test-access-casing" , "1.0.0" )
386- r .NoError (err , "could not get component version from source" )
387- r .Len (desc .Component .Resources , 1 )
388- r .Equal ("my-chart" , desc .Component .Resources [0 ].Name )
389- r .Equal ("helmChart" , desc .Component .Resources [0 ].Type )
390- r .Equal (tc .expectedAccess , desc .Component .Resources [0 ].Access .GetType ().String (),
391- "access type in descriptor should be normalized to default for %s" , tc .accessType )
392-
393- // Step 2: transfer cv (CTF to CTF, no actual chart download needed for reference transfer)
394- targetArchive := filepath .Join (tmp , "target-archive" )
395- sourceRef := fmt .Sprintf ("ctf::%s//ocm.software/test-access-casing:1.0.0" , sourceArchive )
396- targetRef := fmt .Sprintf ("ctf::%s" , targetArchive )
397-
398- transferLogs := test .NewJSONLogReader ()
399- _ , err = test .OCM (t , test .WithArgs ("transfer" , "component-version" , sourceRef , targetRef ),
400- test .WithErrorOutput (transferLogs ))
401- r .NoError (err , "transfer cv failed for access type %s" , tc .accessType )
402-
403- // Verify target CTF
404- targetFS , err := filesystem .NewFS (targetArchive , os .O_RDONLY )
405- r .NoError (err )
406- targetRepo , err := oci .NewRepository (ocictf .WithCTF (ocictf .NewFromCTF (ctf .NewFileSystemCTF (targetFS ))))
407- r .NoError (err )
408-
409- targetDesc , err := targetRepo .GetComponentVersion (t .Context (), "ocm.software/test-access-casing" , "1.0.0" )
410- r .NoError (err , "could not get component version from target" )
411- r .Len (targetDesc .Component .Resources , 1 )
412- r .Equal ("my-chart" , targetDesc .Component .Resources [0 ].Name )
413- r .Equal ("helmChart" , targetDesc .Component .Resources [0 ].Type )
414- r .Equal (tc .expectedAccess , targetDesc .Component .Resources [0 ].Access .GetType ().String (),
415- "access type in target should be normalized to default for %s" , tc .accessType )
416- })
417- }
418- }
0 commit comments