feat: add realtime snapshot and location APIs

This commit is contained in:
lingniu
2026-07-02 18:41:23 +08:00
parent 44a6bee4ac
commit 0bfd1191cb
5 changed files with 696 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
package realtime
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestOpenAPIHandlerDocumentsRealtimeSnapshotAndLocation(t *testing.T) {
request := httptest.NewRequest(http.MethodGet, "/openapi.json", nil)
response := httptest.NewRecorder()
NewOpenAPIHandler().ServeHTTP(response, request)
if response.Code != http.StatusOK {
t.Fatalf("status = %d body=%s", response.Code, response.Body.String())
}
body := response.Body.String()
for _, want := range []string{`"/api/realtime/snapshots"`, `"/api/realtime/locations"`, `"vehicle_realtime_snapshot"`, `"vehicle_realtime_location"`} {
if !strings.Contains(body, want) {
t.Fatalf("openapi missing %s: %s", want, body)
}
}
}