updated app build

This commit is contained in:
ghostersk
2025-03-02 17:14:05 +00:00
parent bd1c372435
commit af3ffb5d6d
36 changed files with 901 additions and 2384 deletions

View File

@@ -0,0 +1,21 @@
package tests
import (
"os"
"testing"
"golangproxy/config"
)
func TestLoadConfig(t *testing.T) {
// Test loading existing config
// Test creating default config
os.Remove("test_config.yaml")
config, err := config.LoadConfig("test_config.yaml")
if err != nil {
t.Fatalf("Error loading config: %v", err)
}
if config.ListenHTTP != ":80" {
t.Errorf("Expected ListenHTTP :80, got %s", config.ListenHTTP)
}
}

View File

@@ -0,0 +1,15 @@
package tests
import (
"testing"
"golangproxy/proxy"
)
func TestCreateRoute(t *testing.T) {
// Test HTTP target
route := proxy.CreateRoute("http://example.com", false)
if route.Target != "http://example.com" {
t.Errorf("Expected target http://example.com, got %s", route.Target)
}
}

View File

@@ -0,0 +1,9 @@
package tests
import (
"testing"
)
func TestStartServer(t *testing.T) {
// Test requires mocking or running server in a goroutine
}

View File

@@ -0,0 +1,19 @@
package tests
import (
"os"
"testing"
"golangproxy/ssl"
)
func TestEnsureCertFiles(t *testing.T) {
os.RemoveAll("ssl")
err := ssl.EnsureCertFiles("ssl/cert.pem", "ssl/key.pem")
if err != nil {
t.Fatalf("Error generating certs: %v", err)
}
if _, err := os.Stat("ssl/cert.pem"); os.IsNotExist(err) {
t.Error("Certificate file not created")
}
}