oh-my-posh/src/segment_envar_test.go

43 lines
742 B
Go
Raw Normal View History

2020-10-09 10:22:32 -07:00
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())
}