diff --git a/config/config.go b/config/config.go index 4bb52e4..9fbdd2a 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,7 @@ package config import ( - "path" + "path/filepath" "strconv" "strings" "os" @@ -43,7 +43,7 @@ type OSDFConfig struct { // need to manually configure the location of the director endpoint. // func GetPreferredPrefix() string { - arg0 := strings.ToUpper(path.Base(os.Args[0])) + arg0 := strings.ToUpper(filepath.Base(os.Args[0])) log.Errorln("Current arg0:", arg0) underscore_idx := strings.Index(arg0, "_") if underscore_idx != -1 { diff --git a/namespaces_test.go b/namespaces_test.go index 44ddda2..4b39a14 100644 --- a/namespaces_test.go +++ b/namespaces_test.go @@ -73,7 +73,8 @@ func TestMatchNamespace(t *testing.T) { t.Error(err) } viper.Reset() - config.Init() + err = config.Init() + assert.Nil(t, err) ns, err := MatchNamespace("/osgconnect/private/path/to/file.txt") assert.NoError(t, err, "Failed to parse namespace") @@ -158,7 +159,8 @@ func TestFullNamespace(t *testing.T) { func TestDownloadNamespaces(t *testing.T) { os.Setenv("STASH_NAMESPACE_URL", "https://topology-itb.opensciencegrid.org/stashcache/namespaces") viper.Reset() - config.Init() + err := config.Init() + assert.Nil(t, err) fmt.Printf("Prefix %s; STASH_NAMESPACE_URL: %s; config NamespaceURL: %s", config.GetPreferredPrefix(), os.Getenv("STASH_NAMESPACE_URL"), viper.GetString("NamespaceURL")) defer os.Unsetenv("STASH_NAMESPACE_URL") namespaceBytes, err := downloadNamespace() @@ -170,7 +172,8 @@ func TestDownloadNamespaces(t *testing.T) { func TestDownloadNamespacesFail(t *testing.T) { os.Setenv("STASH_NAMESPACE_URL", "https://doesnotexist.org.blah/namespaces.json") viper.Reset() - config.Init() + err := config.Init() + assert.Nil(t, err) defer os.Unsetenv("STASH_NAMESPACE_URL") namespaceBytes, err := downloadNamespace() assert.Error(t, err, "Failed to download namespaces") @@ -181,7 +184,8 @@ func TestGetNamespaces(t *testing.T) { // Set the environment to an invalid URL, so it is forced to use the "built-in" namespaces.json os.Setenv("STASH_NAMESPACE_URL", "https://doesnotexist.org.blah/namespaces.json") viper.Reset() - config.Init() + err := config.Init() + assert.Nil(t, err) defer os.Unsetenv("STASH_NAMESPACE_URL") namespaces, err := GetNamespaces() assert.NoError(t, err, "Failed to get namespaces")