From cc49361bcbf689510035e7bbdcce9d8467a36282 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Fri, 15 Mar 2024 21:45:01 -0400 Subject: add newline, clean up test --- api/cmd/main_test.go | 10 ++-------- api/internal/config/config.go | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/api/cmd/main_test.go b/api/cmd/main_test.go index 049cf6e..a4db57a 100644 --- a/api/cmd/main_test.go +++ b/api/cmd/main_test.go @@ -8,15 +8,12 @@ import ( "testing" "water/api/internal/router" - "github.com/spf13/viper" "github.com/stretchr/testify/assert" + "water/api/internal/config" ) func getTestUserCredentials() (string, string) { - viper.SetConfigFile("../.env") - viper.AddConfigPath(".") - viper.AutomaticEnv() - err := viper.ReadInConfig() + viper, err := config.Load() if err != nil { log.Fatalf("Error while reading config file %s", err) } @@ -31,9 +28,6 @@ func TestAuthRoute(t *testing.T) { username, password := getTestUserCredentials() - log.Println("username", username) - log.Println("password", password) - w := httptest.NewRecorder() req, err := http.NewRequest("POST", "/api/v1/auth", nil) if err != nil { diff --git a/api/internal/config/config.go b/api/internal/config/config.go index 1892696..d54e40e 100644 --- a/api/internal/config/config.go +++ b/api/internal/config/config.go @@ -14,4 +14,4 @@ func Load() (*viper.Viper, error) { return nil, fmt.Errorf("error reading .env file: %s", err) } return v, nil -} \ No newline at end of file +} -- cgit v1.1