-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change environment variable name and default (#439)
- Loading branch information
1 parent
1054e1c
commit bf24f62
Showing
5 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <hello@hypermode.com> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package config | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestEnvironmentNames(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
envValue string | ||
expectedResult string | ||
isDev bool | ||
}{ | ||
{ | ||
name: "Environment variable not set", | ||
envValue: "", | ||
expectedResult: "prod", | ||
isDev: false, | ||
}, | ||
{ | ||
name: "Environment variable set to dev", | ||
envValue: "dev", | ||
expectedResult: "dev", | ||
isDev: true, | ||
}, | ||
{ | ||
name: "Environment variable set to development", | ||
envValue: "development", | ||
expectedResult: "development", | ||
isDev: true, | ||
}, | ||
{ | ||
name: "Environment variable set to stage", | ||
envValue: "stage", | ||
expectedResult: "stage", | ||
isDev: false, | ||
}, | ||
{ | ||
name: "Environment variable set to test", | ||
envValue: "test", | ||
expectedResult: "test", | ||
isDev: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
os.Setenv("MODUS_ENV", tt.envValue) | ||
setEnvironmentName() | ||
result := GetEnvironmentName() | ||
if result != tt.expectedResult { | ||
t.Errorf("Expected environment to be %s, but got %s", tt.expectedResult, result) | ||
} | ||
if IsDevEnvironment() != tt.isDev { | ||
t.Errorf("Expected IsDevEnvironment to be %v, but got %v", tt.isDev, IsDevEnvironment()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters