Skip to content

Commit

Permalink
test env util
Browse files Browse the repository at this point in the history
  • Loading branch information
effoeffi committed Mar 20, 2024
1 parent 7e78b93 commit 751c067
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions env/util_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package env_test

import (
"os"
"strconv"
"testing"

"github.com/google/uuid"
"github.com/oasdiff/go-common/env"
"github.com/stretchr/testify/require"
)

func TestGetEnvWithDefault(t *testing.T) {

const value = "http://test.me.com"
require.Equal(t, value, env.GetEnvWithDefault("MY_TEST_CONNECTION", value))
}

func TestGetEnvIntWithDefault(t *testing.T) {

const value = 14
require.Equal(t, value, env.GetEnvIntWithDefault("MY_TEST_CONNECTION", value))
}

func TestGetEnvIntWithDefault_Convert(t *testing.T) {

key := uuid.NewString()
const value = 14

os.Setenv(key, strconv.Itoa(value))
require.Equal(t, value, env.GetEnvIntWithDefault(key, value))
}

0 comments on commit 751c067

Please sign in to comment.