get.porter.sh/porter@v1.3.0/pkg/runtime/context_test.go (about) 1 package runtime 2 3 import ( 4 "testing" 5 6 "get.porter.sh/porter/pkg/config" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestRuntimeConfig_DebugMode(t *testing.T) { 11 testcases := []struct { 12 debugEnv string 13 wantDebug bool 14 }{ 15 {debugEnv: "true", wantDebug: true}, 16 {debugEnv: "1", wantDebug: true}, 17 {debugEnv: "abc", wantDebug: false}, 18 {debugEnv: "", wantDebug: false}, 19 } 20 21 for _, tc := range testcases { 22 tc := tc 23 t.Run(tc.debugEnv, func(t *testing.T) { 24 t.Parallel() 25 26 config := config.NewTestConfig(t) 27 config.Setenv("PORTER_DEBUG", tc.debugEnv) 28 c := NewConfigFor(config.Config) 29 assert.Equal(t, tc.wantDebug, c.DebugMode) 30 }) 31 } 32 } 33 34 func TestNewTestPorterRuntime(t *testing.T) { 35 r := NewTestPorterRuntime(t) 36 assert.True(t, r.config.DebugMode) 37 } 38 39 func TestNewTestRuntimeConfig(t *testing.T) { 40 cfg := NewTestRuntimeConfig(t) 41 assert.True(t, cfg.DebugMode) 42 }