github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/unit_test.go (about) 1 package main 2 3 import ( 4 "github.com/jfrog/jfrog-cli-go/utils/cliutils" 5 "github.com/jfrog/jfrog-cli-go/utils/tests" 6 "github.com/jfrog/jfrog-client-go/utils/log" 7 clientTests "github.com/jfrog/jfrog-client-go/utils/tests" 8 "os" 9 "path/filepath" 10 "testing" 11 ) 12 13 const ( 14 JfrogTestsHome = ".jfrogTest" 15 CliIntegrationTests = "github.com/jfrog/jfrog-cli-go" 16 ) 17 18 func TestUnitTests(t *testing.T) { 19 homePath, err := filepath.Abs(JfrogTestsHome) 20 if err != nil { 21 log.Error(err) 22 os.Exit(1) 23 } 24 25 setJfrogHome(homePath) 26 packages := clientTests.GetTestPackages("./...") 27 packages = clientTests.ExcludeTestsPackage(packages, CliIntegrationTests) 28 clientTests.RunTests(packages, *tests.HideUnitTestLog) 29 cleanUnitTestsJfrogHome(homePath) 30 } 31 32 func setJfrogHome(homePath string) { 33 if err := os.Setenv(cliutils.HomeDir, homePath); err != nil { 34 log.Error(err) 35 os.Exit(1) 36 } 37 } 38 39 func cleanUnitTestsJfrogHome(homePath string) { 40 os.RemoveAll(homePath) 41 if err := os.Unsetenv(cliutils.HomeDir); err != nil { 42 os.Exit(1) 43 } 44 }