Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Jun 11, 2023
1 parent f041971 commit 2ff3c1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package config

import (
"path"
"path/filepath"
"strconv"
"strings"
"os"
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 2ff3c1a

Please sign in to comment.