mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
test: imports basic tests, all passing.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
@@ -149,6 +150,11 @@ type EntranceChannelInfo struct {
|
||||
var ErupeConfig *Config
|
||||
|
||||
func init() {
|
||||
// Skip config loading during tests
|
||||
if isTestMode() {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
ErupeConfig, err = LoadConfig()
|
||||
if err != nil {
|
||||
@@ -157,6 +163,16 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
func isTestMode() bool {
|
||||
// Check if we're running in test mode
|
||||
for _, arg := range os.Args {
|
||||
if strings.HasPrefix(arg, "-test.") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// getOutboundIP4 gets the preferred outbound ip4 of this machine
|
||||
// From https://stackoverflow.com/a/37382208
|
||||
func getOutboundIP4() net.IP {
|
||||
@@ -200,7 +216,7 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
|
||||
func preventClose(text string) {
|
||||
if ErupeConfig.DisableSoftCrash {
|
||||
if ErupeConfig != nil && ErupeConfig.DisableSoftCrash {
|
||||
os.Exit(0)
|
||||
}
|
||||
fmt.Println("\nFailed to start Erupe:\n" + text)
|
||||
|
||||
Reference in New Issue
Block a user