Production state

This commit is contained in:
2026-07-13 01:26:49 +08:00
parent 7cb409f5a6
commit 8c6e6a54cc
21 changed files with 769 additions and 76 deletions
+34
View File
@@ -0,0 +1,34 @@
package app
import (
"os"
"path/filepath"
"testing"
)
func TestLoadDotEnv(t *testing.T) {
path := filepath.Join(t.TempDir(), ".env")
contents := "# comment\nDOTENV_TEST_ONE=value\nDOTENV_TEST_TWO=Preface Tools - Comic Animator\nDOTENV_TEST_THREE=\"quoted value\"\n"
if err := os.WriteFile(path, []byte(contents), 0600); err != nil {
t.Fatal(err)
}
t.Setenv("DOTENV_TEST_ONE", "existing")
if err := LoadDotEnv(path); err != nil {
t.Fatal(err)
}
if got := os.Getenv("DOTENV_TEST_ONE"); got != "existing" {
t.Fatalf("existing environment overwritten: %q", got)
}
if got := os.Getenv("DOTENV_TEST_TWO"); got != "Preface Tools - Comic Animator" {
t.Fatalf("unquoted value: %q", got)
}
if got := os.Getenv("DOTENV_TEST_THREE"); got != "quoted value" {
t.Fatalf("quoted value: %q", got)
}
}
func TestLoadDotEnvMissingFile(t *testing.T) {
if err := LoadDotEnv(filepath.Join(t.TempDir(), "missing")); err != nil {
t.Fatal(err)
}
}