add support for env variables to the DSL

This commit is contained in:
2025-09-02 00:54:38 -06:00
parent c6f14e1787
commit 69f507f176
12 changed files with 842 additions and 84 deletions

View File

@ -4,6 +4,35 @@ import (
"testing"
)
// Helper functions for creating ConfigValue and IntValue instances
func literalConfigValue(value string) *ConfigValue {
return &ConfigValue{Literal: &value}
}
func literalIntValue(value int) *IntValue {
return &IntValue{Literal: &value}
}
func envConfigValue(name string, defaultValue *string, required bool) *ConfigValue {
return &ConfigValue{
EnvVar: &EnvVar{
Name: name,
Default: defaultValue,
Required: required,
},
}
}
func envIntValue(name string, defaultValue *string, required bool) *IntValue {
return &IntValue{
EnvVar: &EnvVar{
Name: name,
Default: defaultValue,
Required: required,
},
}
}
func TestParseServerDefinitions(t *testing.T) {
tests := []struct {
name string
@ -23,8 +52,8 @@ func TestParseServerDefinitions(t *testing.T) {
Server: &Server{
Name: "MyApp",
Settings: []ServerSetting{
{Host: stringPtr("localhost")},
{Port: intPtr(8080)},
{Host: literalConfigValue("localhost")},
{Port: literalIntValue(8080)},
},
},
},
@ -43,7 +72,7 @@ func TestParseServerDefinitions(t *testing.T) {
Server: &Server{
Name: "WebApp",
Settings: []ServerSetting{
{Host: stringPtr("0.0.0.0")},
{Host: literalConfigValue("0.0.0.0")},
},
},
},
@ -62,7 +91,7 @@ func TestParseServerDefinitions(t *testing.T) {
Server: &Server{
Name: "APIServer",
Settings: []ServerSetting{
{Port: intPtr(3000)},
{Port: literalIntValue(3000)},
},
},
},