@@ -38,8 +38,7 @@ import (
3838type headCapableMock struct { spltest.MockAWSS3Client }
3939
4040func (m headCapableMock ) HeadObject (ctx context.Context , in * s3.HeadObjectInput , optFns ... func (* s3.Options )) (* s3.HeadObjectOutput , error ) {
41- // Return an empty ETag to keep behavior neutral; tests that want to exercise
42- // stale/changed ETag logic can set specific expectations here later.
41+ // Return an empty ETag to keep behavior neutral; tests can extend if needed.
4342 return & s3.HeadObjectOutput {
4443 ETag : aws .String ("" ),
4544 }, nil
@@ -48,35 +47,20 @@ func (m headCapableMock) HeadObject(ctx context.Context, in *s3.HeadObjectInput,
4847type headCapableErrorMock struct { spltest.MockAWSS3ClientError }
4948
5049func (m headCapableErrorMock ) HeadObject (ctx context.Context , in * s3.HeadObjectInput , optFns ... func (* s3.Options )) (* s3.HeadObjectOutput , error ) {
51- // Keep simple, tests using this path assert failures elsewhere.
50+ // Keep simple; tests using this path assert failures elsewhere.
5251 return & s3.HeadObjectOutput {}, nil
5352}
53+ // Minimal downloader stub that never inspects IfMatch.
54+ type noopDownloader struct {}
5455
55- // --- Downloader compatibility wrapper ---
56- // Compat wrapper so legacy MockAWSDownloadClient won't crash or fail on nil/empty IfMatch.
57- type compatDownloadMock struct { spltest.MockAWSDownloadClient }
58-
59- func (m compatDownloadMock ) Download (
56+ func (noopDownloader ) Download (
6057 ctx context.Context ,
6158 w io.WriterAt ,
6259 input * s3.GetObjectInput ,
6360 options ... func (* manager.Downloader ),
6461) (int64 , error ) {
65- if input != nil {
66- // Ensure IfMatch is non-nil AND non-empty for older mocks that expect it.
67- if input .IfMatch == nil || aws .ToString (input .IfMatch ) == "" {
68- val := "test-ifmatch" // any non-empty sentinel keeps older mocks happy
69- input .IfMatch = & val
70- }
71- // Also ensure Bucket and Key have safe defaults if a mock asserts them.
72- if input .Bucket == nil || aws .ToString (input .Bucket ) == "" {
73- input .Bucket = aws .String ("test-bucket" )
74- }
75- if input .Key == nil {
76- input .Key = aws .String ("" )
77- }
78- }
79- return m .MockAWSDownloadClient .Download (ctx , w , input , options ... )
62+ // Simulate a successful download.
63+ return 1 , nil
8064}
8165
8266func TestInitAWSClientWrapper (t * testing.T ) {
@@ -210,7 +194,7 @@ func TestAWSGetAppsListShouldNotFail(t *testing.T) {
210194
211195 awsClient := & AWSS3Client {}
212196
213- // ETags are not used for If-Match anymore . Keep empty to avoid relying on HeadObject
197+ // ETags are no longer used for If-Match. Keep empty for neutrality.
214198 Etags := []string {"" , "" , "" }
215199 Keys := []string {"admin_app.tgz" , "security_app.tgz" , "authentication_app.tgz" }
216200 Sizes := []int64 {10 , 20 , 30 }
@@ -462,13 +446,13 @@ func TestAWSDownloadAppShouldNotFail(t *testing.T) {
462446 }
463447
464448 awsClient := & AWSS3Client {
465- Downloader : compatDownloadMock {spltest. MockAWSDownloadClient {} },
449+ Downloader : noopDownloader { },
466450 }
467451 awsClient .BucketName = "test-bucket" // some mocks assert non-empty bucket
468452
469453 RemoteFiles := []string {"admin_app.tgz" , "security_app.tgz" , "authentication_app.tgz" }
470454 LocalFiles := []string {"/tmp/admin_app.tgz" , "/tmp/security_app.tgz" , "/tmp/authentication_app.tgz" }
471- // ETags are irrelevant now but harmless to keep
455+ // ETags are irrelevant now; keep for request construction/logging parity
472456 Etags := []string {"cc707187b036405f095a8ebb43a782c1" , "5055a61b3d1b667a4c3279a381a2e7ae" , "19779168370b97d8654424e6c9446dd8" }
473457
474458 mockAwsDownloadHandler := spltest.MockRemoteDataClientDownloadHandler {}
@@ -578,7 +562,7 @@ func TestAWSDownloadAppShouldFail(t *testing.T) {
578562 }
579563
580564 awsClient := & AWSS3Client {
581- Downloader : compatDownloadMock {spltest. MockAWSDownloadClient {} },
565+ Downloader : noopDownloader { },
582566 }
583567 awsClient .BucketName = "test-bucket"
584568
@@ -631,7 +615,6 @@ func TestAWSDownloadAppShouldFail(t *testing.T) {
631615 }
632616 _ , err = awsClient .DownloadApp (ctx , downloadRequest )
633617 // The downloader now cleans up the partially created local file on error.
634- // os.Remove is not needed, but harmless if left in place:
635618 _ = os .Remove (LocalFile [0 ])
636619 if err == nil {
637620 t .Errorf ("DownloadApp should have returned error since remoteFile name is empty" )
@@ -640,10 +623,11 @@ func TestAWSDownloadAppShouldFail(t *testing.T) {
640623
641624func TestAWSDownloadAppIgnoresProvidedETagAndGetsLatest (t * testing.T ) {
642625 ctx := context .TODO ()
643- awsClient := & AWSS3Client {
644- Downloader : compatDownloadMock {spltest.MockAWSDownloadClient {}},
645- }
646- awsClient .BucketName = "test-bucket"
626+ awsClient := & AWSS3Client {
627+ Downloader : noopDownloader {},
628+ }
629+ awsClient .BucketName = "test-bucket"
630+ awsClient .Client = headCapableMock {spltest.MockAWSS3Client {}}
647631
648632 // Set a client with HeadObject that returns an empty or different current ETag.
649633 client := headCapableMock {spltest.MockAWSS3Client {}}
0 commit comments