@@ -18,13 +18,12 @@ package artifact
1818
1919import (
2020 "fmt"
21- "os"
22- "path/filepath"
23- "testing"
24-
2521 "github.com/aws/amazon-ssm-agent/agent/mocks/context"
2622 "github.com/aws/amazon-ssm-agent/agent/mocks/log"
2723 "github.com/stretchr/testify/assert"
24+ "os"
25+ "path/filepath"
26+ "testing"
2827)
2928
3029type DownloadTest struct {
@@ -234,15 +233,15 @@ func TestDownloads(t *testing.T) {
234233}
235234
236235func TestHttpHttpsDownloadArtifact (t * testing.T ) {
237- testFilePath := "https://www.ietf.org/rfc/rfc1350.txt "
236+ testFilePath := "https://amazon-ssm-us-east-1.s3.amazonaws.com/3.3.40.0/VERSION "
238237 downloadInput := DownloadInput {
239238 DestinationDirectory : "." ,
240239 SourceURL : testFilePath ,
241240 SourceChecksums : map [string ]string {
242- "sha256" : "39c9534e5fa6fecd3ac083ffd6256c2cc9a58f9f1058cb2e472d1782040231f9 " ,
241+ "sha256" : "0c0f36c238e6c4c00f39d94dc6381930df2851db0ea2e2543d931474ddce1f8f " ,
243242 },
244243 }
245- var expectedLocalPath = "dd5335f3e07903892245d100f4d7df03067e6402 "
244+ var expectedLocalPath = "b9f961391ec1ae061db3afcbed5571b2463139c8 "
246245 os .Remove (expectedLocalPath )
247246 os .Remove (expectedLocalPath + ".etag" )
248247 expectedOutput := DownloadOutput {
@@ -253,6 +252,11 @@ func TestHttpHttpsDownloadArtifact(t *testing.T) {
253252 output , err := Download (mockContext , downloadInput )
254253 assert .NoError (t , err , "Failed to download %v" , downloadInput )
255254 mockLog .Infof ("Download Result is %v and err:%v" , output , err )
255+
256+ defer func () {
257+ os .Remove (expectedLocalPath )
258+ os .Remove (expectedLocalPath + ".etag" )
259+ }()
256260 assert .Equal (t , expectedOutput , output )
257261
258262 // now since we have downloaded the file, try to download again should result in cache hit!
@@ -264,9 +268,6 @@ func TestHttpHttpsDownloadArtifact(t *testing.T) {
264268 assert .NoError (t , err , "Failed to download %v" , downloadInput )
265269 mockLog .Infof ("Download Result is %v and err:%v" , output , err )
266270 assert .Equal (t , expectedOutput , output )
267-
268- os .Remove (expectedLocalPath )
269- os .Remove (expectedLocalPath + ".etag" )
270271}
271272
272273func ExampleMd5HashValue () {
0 commit comments