Skip to content

Commit

Permalink
Move helper funtion getEnv from client_test.go to tools.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Nosmoht committed Mar 26, 2020
1 parent a1d7a04 commit 326dd70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 0 additions & 9 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
package client

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func getEnv(key, fallback string) string {
value, exist := os.LookupEnv(key)
if !exist {
return fallback
}
return value
}

func getDefaultConfig() Config {
return Config{
URL: getEnv("NEXUS_URL", "http://127.0.0.1:8081"),
Expand Down
8 changes: 8 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"os"
)

func jsonMarshalInterfaceToIOReader(data interface{}) (io.Reader, error) {
Expand All @@ -15,3 +16,10 @@ func jsonMarshalInterfaceToIOReader(data interface{}) (io.Reader, error) {

return bytes.NewReader(b), nil
}

func getEnv(key, fallback string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
return fallback
}

0 comments on commit 326dd70

Please sign in to comment.