Files
query-orchestration/api/queryAPI/export_test.go
T

45 lines
1.0 KiB
Go
Raw Normal View History

package queryapi_test
2025-01-15 19:45:51 +00:00
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
queryapi "queryorchestration/api/queryAPI"
2025-03-05 12:05:46 +00:00
"github.com/google/uuid"
2025-01-15 19:45:51 +00:00
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
)
func TestTriggerExport(t *testing.T) {
e := echo.New()
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(""))
rec := httptest.NewRecorder()
ctx := e.NewContext(req, rec)
cons := queryapi.NewControllers(&queryapi.Services{})
2025-01-15 19:45:51 +00:00
err := cons.TriggerExport(ctx, "clientid")
assert.NoError(t, err)
2025-01-15 19:45:51 +00:00
assert.Equal(t, http.StatusOK, rec.Code)
assert.NotEmpty(t, rec.Body.String())
}
func TestExportState(t *testing.T) {
e := echo.New()
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(""))
rec := httptest.NewRecorder()
ctx := e.NewContext(req, rec)
cons := queryapi.NewControllers(&queryapi.Services{})
id := uuid.New()
err := cons.ExportState(ctx, id)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, rec.Code)
assert.NotEmpty(t, rec.Body.String())
}