feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
35
internal/netaddr/main_test.go
Обычный файл
35
internal/netaddr/main_test.go
Обычный файл
@@ -0,0 +1,35 @@
|
||||
package netaddr
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
// TestMain loads .env.test before any test runs so DATABASE_* env vars
|
||||
// are populated in this test binary. The netaddr package is intentionally
|
||||
// low-level and does not import config/env; this TestMain gives it the
|
||||
// same environment the rest of the test suite sees without pulling in
|
||||
// the app-wide env init.
|
||||
func TestMain(m *testing.M) {
|
||||
loadEnvIfPresent(".env.test")
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func loadEnvIfPresent(name string) {
|
||||
candidates := []string{name}
|
||||
if cwd := os.Getenv("CWD"); cwd != "" {
|
||||
candidates = append(candidates, filepath.Join(cwd, name))
|
||||
}
|
||||
if dir, err := os.Getwd(); err == nil {
|
||||
candidates = append(candidates, filepath.Join(dir, name))
|
||||
}
|
||||
for _, c := range candidates {
|
||||
if _, err := os.Stat(c); err == nil {
|
||||
_ = godotenv.Load(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user