MCPcopy Create free account
hub / github.com/coder/envbox / TestMustLookupEnv

Function TestMustLookupEnv

xunix/env_test.go:12–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestMustLookupEnv(t *testing.T) {
13 t.Parallel()
14
15 t.Run("OK", func(t *testing.T) {
16 t.Parallel()
17
18 const (
19 key = "MY_ENV"
20 value = "value"
21 )
22
23 //nolint can't use t.SetEnv in parallel tests.
24 os.Setenv(key, value)
25
26 val := xunix.MustLookupEnv(key)
27 require.Equal(t, value, val)
28 })
29
30 t.Run("Panic", func(t *testing.T) {
31 t.Parallel()
32
33 defer func() {
34 e := recover()
35 require.NotNil(t, e, "function should panic")
36 }()
37 _ = xunix.MustLookupEnv("ASDasdf")
38 })
39}

Callers

nothing calls this directly

Calls 2

MustLookupEnvFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected