updated app build
This commit is contained in:
21
golangproxy/tests/config_test.go
Normal file
21
golangproxy/tests/config_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
15
golangproxy/tests/proxy_test.go
Normal file
15
golangproxy/tests/proxy_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
9
golangproxy/tests/server_test.go
Normal file
9
golangproxy/tests/server_test.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStartServer(t *testing.T) {
|
||||
// Test requires mocking or running server in a goroutine
|
||||
}
|
||||
19
golangproxy/tests/ssl_test.go
Normal file
19
golangproxy/tests/ssl_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user