The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/util/osutil/osutil_test.go

35 lines
751 B

package osutil
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRealEnv(t *testing.T) {
// testing here is obviously not parallel since we do need to access real
// environment variables from the os
const key = "MEREKETENGUE"
const value = "IS ALIVE"
assert.Equal(t, os.Getenv(key), RealEnv{}.Getenv(key))
assert.NoError(t, RealEnv{}.Setenv(key, value))
assert.Equal(t, value, RealEnv{}.Getenv(key))
assert.Equal(t, value, os.Getenv(key))
}
func TestMapEnv(t *testing.T) {
t.Parallel()
const key = "THE_THING"
const value = "IS ALIVE"
e := MapEnv{}
assert.Empty(t, e.Getenv(key))
assert.Len(t, e, 0)
assert.NoError(t, e.Setenv(key, value))
assert.Equal(t, value, e.Getenv(key))
assert.Len(t, e, 1)
}