github.com/apptainer/singularity@v3.1.1+incompatible/pkg/client/shub/pull_test.go (about) 1 // Copyright (c) 2018, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package client 7 8 import ( 9 "os" 10 "testing" 11 12 "github.com/sylabs/singularity/internal/pkg/test" 13 ) 14 15 const ( 16 shubURI = "shub://ikaneshiro/singularityhub:latest" 17 shubImgPath = "/tmp/shub-test_img.simg" 18 ) 19 20 // TestDownloadImage tests if we can pull an image from Singularity Hub 21 func TestDownloadImage(t *testing.T) { 22 23 if testing.Short() { 24 t.SkipNow() 25 } 26 27 test.DropPrivilege(t) 28 defer test.ResetPrivilege(t) 29 30 err := DownloadImage(shubImgPath, shubURI, false, false) 31 if err != nil { 32 t.Fatalf("failed to Get from %s: %v\n", shubURI, err) 33 } 34 35 //clean up 36 err = os.Remove(shubImgPath) 37 if err != nil { 38 t.Fatalf("failed to clean up test environment: %v", err) 39 } 40 }