oh-my-posh/segment_envar_test.go
2020-10-09 20:54:41 +02:00

43 lines
742 B
Go

package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEnvvarAvailable(t *testing.T) {
name := "HERP"
expected := "derp"
env := new(MockedEnvironment)
env.On("getenv", name).Return(expected)
props := &properties{
values: map[Property]interface{}{
VarName: name,
},
}
e := &envvar{
env: env,
props: props,
}
assert.True(t, e.enabled())
assert.Equal(t, expected, e.string())
}
func TestEnvvarNotAvailable(t *testing.T) {
name := "HERP"
expected := ""
env := new(MockedEnvironment)
env.On("getenv", name).Return(expected)
props := &properties{
values: map[Property]interface{}{
VarName: name,
},
}
e := &envvar{
env: env,
props: props,
}
assert.False(t, e.enabled())
}