// Copyright 2024 Matthew Rich . All rights reserved. package folio import ( _ "fmt" _ "github.com/stretchr/testify/assert" "log" "os" "os/user" "os/exec" _ "path/filepath" "testing" ) var TempDir string var ProcessTestUserName string var ProcessTestGroupName string func TestMain(m *testing.M) { var err error TempDir, err = os.MkdirTemp("", "testfolio") if err != nil || TempDir == "" { log.Fatal(err) } ProcessTestUserName, ProcessTestGroupName = ProcessUserName() RegisterMocks() rc := m.Run() os.RemoveAll(TempDir) os.Exit(rc) } func ProcessUserName() (string, string) { processUser, userErr := user.Current() if userErr != nil { panic(userErr) } processGroup, groupErr := user.LookupGroupId(processUser.Gid) if groupErr != nil { panic(groupErr) } return processUser.Username, processGroup.Name } func ExitError(e error) string { if e != nil { switch v := e.(type) { case *exec.ExitError: return string(v.Stderr) default: return e.Error() } } return "" }