oh-my-posh/src/segment_envar_test.go
2020-12-25 20:11:24 +01: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())
}