- Move assets from internal/assets to top-level assets/ package for clean embed directive - Consolidate all static files in single location (assets/static/) - Remove duplicate static file locations to maintain single source of truth - Add Reset Map button to map controls with full functionality - Implement resetMap() method to return map to calculated origin position - Store origin in this.mapOrigin for reset functionality - Fix go:embed pattern to work without parent directory references 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1 KiB
Go
55 lines
1 KiB
Go
package server
|
|
|
|
import (
|
|
"embed"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"skyview/internal/config"
|
|
)
|
|
|
|
//go:embed testdata/*
|
|
var testStaticFiles embed.FS
|
|
|
|
func TestNew(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Server: config.ServerConfig{
|
|
Address: ":8080",
|
|
Port: 8080,
|
|
},
|
|
Dump1090: config.Dump1090Config{
|
|
Host: "localhost",
|
|
Port: 8080,
|
|
URL: "http://localhost:8080",
|
|
},
|
|
}
|
|
|
|
handler := New(cfg, testStaticFiles)
|
|
if handler == nil {
|
|
t.Fatal("Expected handler to be created")
|
|
}
|
|
}
|
|
|
|
func TestCORSHeaders(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Dump1090: config.Dump1090Config{
|
|
URL: "http://localhost:8080",
|
|
},
|
|
}
|
|
|
|
handler := New(cfg, testStaticFiles)
|
|
|
|
req := httptest.NewRequest("OPTIONS", "/api/aircraft", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
handler.ServeHTTP(w, req)
|
|
|
|
if w.Header().Get("Access-Control-Allow-Origin") != "*" {
|
|
t.Errorf("Expected CORS header, got %s", w.Header().Get("Access-Control-Allow-Origin"))
|
|
}
|
|
|
|
if w.Code != http.StatusOK {
|
|
t.Errorf("Expected status 200, got %d", w.Code)
|
|
}
|
|
}
|