2018-03-20 01:28:59 +01:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
2019-07-09 18:11:01 +02:00
|
|
|
"os"
|
2019-07-09 19:49:17 +02:00
|
|
|
"testing"
|
2018-03-20 01:28:59 +01:00
|
|
|
)
|
|
|
|
|
2019-07-09 19:49:17 +02:00
|
|
|
func TestValidatePort(t *testing.T) {
|
2018-03-20 01:28:59 +01:00
|
|
|
|
2019-07-09 19:49:17 +02:00
|
|
|
Config = new(ConfigType)
|
2018-03-20 01:28:59 +01:00
|
|
|
Config.Port = ""
|
|
|
|
validatePort()
|
|
|
|
if Config.Port != ":3000" {
|
|
|
|
t.Error("no port should get set to default")
|
|
|
|
}
|
|
|
|
|
|
|
|
Config.Port = "4000"
|
|
|
|
validatePort()
|
|
|
|
if Config.Port != ":4000" {
|
|
|
|
t.Error("Port without : suffix should have it added")
|
|
|
|
}
|
|
|
|
|
|
|
|
os.Setenv("PORT", "5000")
|
|
|
|
validatePort()
|
|
|
|
if Config.Port != ":5000" {
|
|
|
|
t.Error("Port value should be overwritten by env var, and it should be prefixed appropriately")
|
|
|
|
}
|
2019-07-09 19:49:17 +02:00
|
|
|
}
|