MCPcopy Create free account
hub / github.com/astercloud/aster / TestExpandVariablesWithCustomVariables

Function TestExpandVariablesWithCustomVariables

pkg/config/loader_test.go:121–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestExpandVariablesWithCustomVariables(t *testing.T) {
122 loader := NewLoader(WithVariables(map[string]string{
123 "CUSTOM_VAR": "custom_value",
124 }))
125
126 result := loader.expandVariables("${CUSTOM_VAR}")
127 if result != "custom_value" {
128 t.Errorf("expected 'custom_value', got %q", result)
129 }
130
131 // Custom variables should take precedence over environment
132 _ = os.Setenv("CUSTOM_VAR", "env_value")
133 defer func() { _ = os.Unsetenv("CUSTOM_VAR") }()
134
135 result = loader.expandVariables("${CUSTOM_VAR}")
136 if result != "custom_value" {
137 t.Errorf("expected custom variable to take precedence, got %q", result)
138 }
139}
140
141func TestExpandVariablesDisabled(t *testing.T) {
142 _ = os.Setenv("TEST_VAR", "test_value")

Callers

nothing calls this directly

Calls 3

expandVariablesMethod · 0.95
WithVariablesFunction · 0.85
NewLoaderFunction · 0.70

Tested by

no test coverage detected