add support for env variables to the DSL
This commit is contained in:
@ -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)},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user