2025-01-15 19:45:51 +00:00
|
|
|
package queryservice_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/http/httptest"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2025-03-05 12:05:46 +00:00
|
|
|
queryservice "queryorchestration/api/queryService"
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
"github.com/go-playground/validator/v10"
|
2025-01-16 13:49:07 +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 := queryservice.NewControllers(validator.New(), &queryservice.Services{})
|
|
|
|
|
|
|
|
|
|
err := cons.TriggerExport(ctx)
|
2025-02-03 17:30:50 +00:00
|
|
|
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())
|
|
|
|
|
}
|
2025-01-16 13:49:07 +00:00
|
|
|
|
|
|
|
|
func TestExportState(t *testing.T) {
|
|
|
|
|
e := echo.New()
|
|
|
|
|
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(""))
|
|
|
|
|
rec := httptest.NewRecorder()
|
|
|
|
|
ctx := e.NewContext(req, rec)
|
|
|
|
|
|
|
|
|
|
cons := queryservice.NewControllers(validator.New(), &queryservice.Services{})
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
id := uuid.New()
|
2025-01-16 13:49:07 +00:00
|
|
|
|
|
|
|
|
err := cons.ExportState(ctx, id)
|
2025-02-03 17:30:50 +00:00
|
|
|
assert.NoError(t, err)
|
2025-01-16 13:49:07 +00:00
|
|
|
assert.Equal(t, http.StatusOK, rec.Code)
|
|
|
|
|
assert.NotEmpty(t, rec.Body.String())
|
|
|
|
|
}
|