From 7ecb60daffbd2021bdd904d49c61d98505553cf1 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Thu, 14 Nov 2024 14:47:11 +0100
Subject: [PATCH] OZG-6747 resovle comments

---
 README.md                                      | 14 ++++++++++++--
 internal/config/config.go                      |  6 +++---
 internal/config/config_test.go                 |  7 +++----
 internal/config/testdata/empty_test_config.yml |  0
 4 files changed, 18 insertions(+), 9 deletions(-)
 delete mode 100644 internal/config/testdata/empty_test_config.yml

diff --git a/README.md b/README.md
index 776f307..ce2d75e 100644
--- a/README.md
+++ b/README.md
@@ -42,13 +42,21 @@ buf generate
 ### Anwendung starten
 
 ```
-go run cmd/antragsraum-proxy/main.go
+ACTIVE_PROFILE=local go run cmd/antragsraum-proxy/main.go
 ```
 
-## Config
+
+
+## Config 
+config.yml is the default config for deployment
 
 [Config-Datei](./config/config.yml)
 
+config-local.yml is the config file for local development 
+setting ACTIVE_PROFILE=local will load the config-local.yml
+
+[Config-Datei](./config/config-local.yml)
+
 ```
 http:
   server:
@@ -63,6 +71,8 @@ logging:
   level: "ERROR" | "WARN" | "INFO" | "DEBUG"
 ```
 
+
+
 ### Releasing
 
 Diese Schritte ausführen:
diff --git a/internal/config/config.go b/internal/config/config.go
index 5f32cec..a21874c 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -36,7 +36,7 @@ import (
 const (
 	defaultConfig   = "config.yml"
 	testFilePath = "testdata/"
-	APP_ENV_NAME = "APP_ENV"
+	activeProfile = "ACTIVE_PROFILE"
 )
 
 type Config struct {
@@ -64,7 +64,7 @@ func LoadConfig(configFilePath ...string) Config {
 
 	configFile := defaultConfig
 	
-	env := os.Getenv(APP_ENV_NAME)
+	env := os.Getenv(activeProfile)
 	if env != "" {
 		configFile = fmt.Sprintf("config-%s.yml", env)
 	}
@@ -73,7 +73,7 @@ func LoadConfig(configFilePath ...string) Config {
 	
 	if len(configFilePath) > 0 {
 		fp = configFilePath[0]
-	}  else if testing.Testing() {
+	} else if testing.Testing() {
 		fp = testFilePath+configFile
 	}
 
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 106bf2c..f087729 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -32,7 +32,7 @@ import (
 )
 
 func TestLoadConfig(t *testing.T) {
-	t.Run("should load default config from file", func(t *testing.T) {
+	t.Run("should load default config", func(t *testing.T) {
 		config := LoadConfig()
 
 		expectedConfig := Config{}
@@ -46,12 +46,11 @@ func TestLoadConfig(t *testing.T) {
 	})
 
 	t.Run("should load local config", func(t *testing.T) {
-		os.Setenv(APP_ENV_NAME, "local")
-	    defer os.Unsetenv(APP_ENV_NAME) 
+		assert.NoError(t, os.Setenv(activeProfile, "local"), "Setenv "+activeProfile+" should not return an error") 
 
 		config := LoadConfig()
 
-		assert.NoError(t, os.Unsetenv(APP_ENV_NAME), "Unsetenv "+APP_ENV_NAME+" should not return an error")
+		assert.NoError(t, os.Unsetenv(activeProfile), "Unsetenv "+activeProfile+" should not return an error")
 		
 		expectedConfig := Config{}
 		expectedConfig.Grpc.Server.Mock = true
diff --git a/internal/config/testdata/empty_test_config.yml b/internal/config/testdata/empty_test_config.yml
deleted file mode 100644
index e69de29..0000000
-- 
GitLab