Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package common
import (
"testing"
"reflect"
"fiskerinc.com/modules/logger"
)
func TestStringToTrexLogLevel(t *testing.T){
level := UnmarshalLogLevelString("Warning")
if level != Warn{
t.Fail()
}
level = UnmarshalLogLevelString("ErRoR")
if level != Error{
t.Fail()
}
}
func TestLogLevelToLogger(t *testing.T){
log := Debug.ToLoggerLevel()
if !compareLevel(log(), logger.Debug()){
t.Error("Debug did not give debug logger")
}
log = Error.ToLoggerLevel()
if !compareLevel(log(), logger.Error()){
t.Error("Error did not give error logger")
}
log = Critical.ToLoggerLevel()
if !compareLevel(log(), logger.Error()){
t.Error("Critical did not give error logger")
}
}
func compareLevel(our, theirs *logger.Event)(match bool){
// If the log level is too low, such as debug, the event comes back as null
// Surprisingly calling .Msg does not cause an error on it though
if *our == *theirs{
return true
}
ourVal := reflect.ValueOf(*our).FieldByName("level")
theirVal := reflect.ValueOf(*theirs).FieldByName("level")
return ourVal.Int() == theirVal.Int()
}