MCPcopy Index your code
hub / github.com/coder/coder / TestMergeExtraEnvs

Function TestMergeExtraEnvs

coderd/provisionerdserver/mergeenvs_test.go:12–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestMergeExtraEnvs(t *testing.T) {
13 t.Parallel()
14
15 tests := []struct {
16 name string
17 initial map[string]string
18 envs []*sdkproto.Env
19 expected map[string]string
20 expectErr string
21 }{
22 {
23 name: "empty",
24 initial: map[string]string{},
25 envs: nil,
26 expected: map[string]string{},
27 },
28 {
29 name: "default_replace",
30 initial: map[string]string{},
31 envs: []*sdkproto.Env{
32 {Name: "FOO", Value: "bar"},
33 },
34 expected: map[string]string{"FOO": "bar"},
35 },
36 {
37 name: "explicit_replace",
38 initial: map[string]string{"FOO": "old"},
39 envs: []*sdkproto.Env{
40 {Name: "FOO", Value: "new", MergeStrategy: "replace"},
41 },
42 expected: map[string]string{"FOO": "new"},
43 },
44 {
45 name: "empty_strategy_defaults_to_replace",
46 initial: map[string]string{"FOO": "old"},
47 envs: []*sdkproto.Env{
48 {Name: "FOO", Value: "new", MergeStrategy: ""},
49 },
50 expected: map[string]string{"FOO": "new"},
51 },
52 {
53 name: "append_to_existing",
54 initial: map[string]string{"PATH": "/usr/bin"},
55 envs: []*sdkproto.Env{
56 {Name: "PATH", Value: "/custom/bin", MergeStrategy: "append"},
57 },
58 expected: map[string]string{"PATH": "/usr/bin:/custom/bin"},
59 },
60 {
61 name: "append_no_existing",
62 initial: map[string]string{},
63 envs: []*sdkproto.Env{
64 {Name: "PATH", Value: "/custom/bin", MergeStrategy: "append"},
65 },
66 expected: map[string]string{"PATH": "/custom/bin"},
67 },
68 {
69 name: "append_to_empty_value",

Callers

nothing calls this directly

Calls 3

MergeExtraEnvsFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected