51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
|
|
package config
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestReadBaseConfig_Basic(t *testing.T) {
|
||
|
|
// Create a temporary config file
|
||
|
|
file, err := os.CreateTemp("", "baseconfig_*.json")
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("failed to create temp file: %v", err)
|
||
|
|
}
|
||
|
|
defer os.Remove(file.Name())
|
||
|
|
|
||
|
|
jsonContent := `{
|
||
|
|
"projects_directory": "/projects",
|
||
|
|
"env": "dev",
|
||
|
|
"static_images": "/static",
|
||
|
|
"public_images": "/public",
|
||
|
|
"php_conf": "/php.ini",
|
||
|
|
"exports": "/exports",
|
||
|
|
"logs": "/logs",
|
||
|
|
"preview_path": "/preview",
|
||
|
|
"data_www": "/data",
|
||
|
|
"nginx_conf": "/nginx.conf",
|
||
|
|
"admin_url": "http://admin",
|
||
|
|
"preview_url": "http://preview",
|
||
|
|
"app_image": "app:v1",
|
||
|
|
"webserver_image": "web:v1",
|
||
|
|
"empty_db": "empty.db",
|
||
|
|
"db": "app.db",
|
||
|
|
"empty_imaages": "empty.img",
|
||
|
|
"deployment_type": "json",
|
||
|
|
"deployment_file": "base.json",
|
||
|
|
"port": 8080
|
||
|
|
}`
|
||
|
|
file.WriteString(jsonContent)
|
||
|
|
file.Close()
|
||
|
|
|
||
|
|
os.Setenv("DEPLOYMENT_TYPE", "json")
|
||
|
|
config, err := ReadBaseConfig(file.Name())
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("ReadBaseConfig failed: %v", err)
|
||
|
|
}
|
||
|
|
// Only check RetryDelaySenconds as that's the only field in BaseConfig now
|
||
|
|
if config.RetryDelaySenconds != 0 {
|
||
|
|
t.Errorf("expected RetryDelaySenconds 0, got %d", config.RetryDelaySenconds)
|
||
|
|
}
|
||
|
|
}
|