snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
20
config/mode/mode.go
Normal file
20
config/mode/mode.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package mode
|
||||
|
||||
const (
|
||||
// Dev for development mode
|
||||
Dev = "dev"
|
||||
// Prod for production mode
|
||||
Prod = "prod"
|
||||
)
|
||||
|
||||
var mode = Dev
|
||||
|
||||
// Set sets the new mode.
|
||||
func Set(newMode string) {
|
||||
mode = newMode
|
||||
}
|
||||
|
||||
// Get returns the current mode.
|
||||
func Get() string {
|
||||
return mode
|
||||
}
|
||||
17
config/mode/mode_test.go
Normal file
17
config/mode/mode_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package mode
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/magiconair/properties/assert"
|
||||
)
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
mode = Prod
|
||||
assert.Equal(t, Prod, Get())
|
||||
}
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
Set(Prod)
|
||||
assert.Equal(t, Prod, mode)
|
||||
}
|
||||
Reference in New Issue
Block a user