26 lines
396 B
Go
26 lines
396 B
Go
package env_test
|
|
|
|
import (
|
|
"gotemplate/internal/env"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetFatal(t *testing.T) {
|
|
name := "test_get_env_var_does_not_exist"
|
|
|
|
value := "value"
|
|
os.Setenv(name, value)
|
|
|
|
returnValue := env.GetFatal(name)
|
|
|
|
assert.Equal(t, value, returnValue)
|
|
|
|
value = ""
|
|
os.Setenv(name, value)
|
|
|
|
assert.Panics(t, func() { env.GetFatal(name) })
|
|
}
|