test: imports basic tests, all passing.

This commit is contained in:
Houmgaor
2025-11-09 12:36:56 +01:00
parent 33a195b864
commit c8c0dae8fe
11 changed files with 1298 additions and 5 deletions

View File

@@ -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)