github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/client/cache/library_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 cache 7 8 import ( 9 "os" 10 "path/filepath" 11 "testing" 12 ) 13 14 func TestLibrary(t *testing.T) { 15 tests := []struct { 16 name string 17 env string 18 expected string 19 }{ 20 {"Default Library", "", filepath.Join(cacheDefault, "library")}, 21 {"Custom Library", cacheCustom, filepath.Join(cacheCustom, "library")}, 22 } 23 24 for _, tt := range tests { 25 t.Run(tt.name, func(t *testing.T) { 26 defer Clean() 27 defer os.Unsetenv(DirEnv) 28 29 os.Setenv(DirEnv, tt.env) 30 31 if r := Library(); r != tt.expected { 32 t.Errorf("Unexpected result: %s (expected %s)", r, tt.expected) 33 } 34 }) 35 } 36 } 37 38 // Will come back to after functionality exists 39 // func TestLibraryImageExists(t *testing.T) { 40 // tests := []struct { 41 // name string 42 // env string 43 // expected string 44 // file []struct { 45 // create bool 46 // sum string 47 // name string 48 // } 49 // }{} 50 // }