Skip to content

Commit

Permalink
Automatically load credentials from .env file for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mdogan committed Jan 31, 2024
1 parent 049521f commit f1b1ed2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode
tmp/
go.work.sum
.env
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module github.com/upstash/vector-go

go 1.20

require github.com/stretchr/testify v1.8.4
require (
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand Down
8 changes: 8 additions & 0 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import (
"os"
"testing"

"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
)

func init() {
err := godotenv.Load()
if err != nil {
panic(err)
}
}

func newTestClient() (*Index, error) {
client := NewIndex(
os.Getenv(UrlEnvProperty),
Expand Down

0 comments on commit f1b1ed2

Please sign in to comment.