Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
39 lines
764 B
Go
39 lines
764 B
Go
package env
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSetDebugAndIsDebug(t *testing.T) {
|
|
t.Setenv(DebugEnvVar, "")
|
|
require.False(t, IsDebug())
|
|
|
|
SetDebug()
|
|
require.True(t, IsDebug())
|
|
}
|
|
|
|
func TestConfigDirFromEnv(t *testing.T) {
|
|
dir := filepath.Join(t.TempDir(), "ignite-config")
|
|
t.Setenv(ConfigDirEnvVar, dir)
|
|
|
|
got, err := ConfigDir()()
|
|
require.NoError(t, err)
|
|
require.Equal(t, dir, got)
|
|
}
|
|
|
|
func TestConfigDirPanicsWithRelativePath(t *testing.T) {
|
|
t.Setenv(ConfigDirEnvVar, "relative/path")
|
|
require.Panics(t, func() {
|
|
_, _ = ConfigDir()()
|
|
})
|
|
}
|
|
|
|
func TestSetConfigDir(t *testing.T) {
|
|
dir := filepath.Join(t.TempDir(), "cfg")
|
|
SetConfigDir(dir)
|
|
require.Equal(t, dir, os.Getenv(ConfigDirEnvVar))
|
|
}
|