From 555b6d420b6a1249eb008cfe833bf964ea211fba Mon Sep 17 00:00:00 2001 From: Michael McGuinness Date: Mon, 17 Mar 2025 18:14:15 +0000 Subject: [PATCH] Merged in feature/docresult (pull request #105) Document Result Endpoint * testing * cleantesting * progress * query * lint * readme * dockerclient * api * passtest * tests * test --- .mockery.yml | 2 +- README.md | 19 +- api/docCleanRunner/runner_test.go | 4 +- api/docInitRunner/runner_test.go | 8 +- api/docSyncRunner/runner_test.go | 4 +- api/docTextRunner/runner_test.go | 7 +- api/{queryService => queryAPI}/api.gen.go | 166 ++-- api/{queryService => queryAPI}/client.go | 6 +- api/{queryService => queryAPI}/client_test.go | 18 +- api/{queryService => queryAPI}/collector.go | 6 +- .../collector_test.go | 18 +- api/{queryService => queryAPI}/controllers.go | 4 +- .../controllers_test.go | 6 +- api/queryAPI/documents.go | 39 + api/queryAPI/documents_test.go | 122 +++ api/{queryService => queryAPI}/export.go | 7 +- api/{queryService => queryAPI}/export_test.go | 8 +- api/{queryService => queryAPI}/parse.go | 2 +- api/{queryService => queryAPI}/parse_test.go | 2 +- api/{queryService => queryAPI}/query.go | 9 +- api/{queryService => queryAPI}/query_test.go | 40 +- api/{queryService => queryAPI}/status.go | 4 +- api/{queryService => queryAPI}/status_test.go | 12 +- api/queryService/documents.go | 26 - api/queryService/documents_test.go | 73 -- api/readme.md | 15 +- cmd/{queryService => queryAPI}/main.go | 20 +- ...=> 00000000000102_document_views.down.sql} | 0 .../00000000000102_document_views.up.sql | 200 +++++ .../00000000000102_job_views.up.sql | 95 -- database/queries/client.sql | 29 +- database/queries/document.sql | 49 +- database/queries/text.sql | 4 +- deployments/compose.local.yaml | 4 +- deployments/prometheus.allmetrics.yaml | 4 +- deployments/readme.md | 21 +- devbox.json | 8 +- devbox.lock | 288 ++---- docs/README.md | 22 +- internal/client/sync/sync_test.go | 2 +- internal/database/repository/client.sql.go | 58 +- internal/database/repository/document.sql.go | 145 ++- internal/database/repository/document_test.go | 24 +- internal/database/repository/job_test.go | 587 ------------ internal/database/repository/result_test.go | 37 +- internal/database/repository/sync_test.go | 846 ++++++++++++++++++ internal/database/repository/text.sql.go | 14 +- internal/database/repository/text_test.go | 7 +- internal/document/clean/clean.go | 2 +- internal/document/clean/clean_test.go | 6 +- internal/document/clean/create_test.go | 4 +- internal/document/get.go | 27 +- internal/document/get_test.go | 39 +- internal/document/init/create_test.go | 14 +- internal/document/list.go | 19 +- internal/document/list_test.go | 11 +- internal/document/service.go | 9 +- internal/document/sync/sync.go | 2 +- internal/document/sync/sync_test.go | 4 +- internal/document/text/create_test.go | 7 +- internal/document/text/extract.go | 2 +- internal/document/text/extract_test.go | 7 +- internal/query/test/test_test.go | 2 +- internal/server/{service => api}/listener.go | 2 +- .../server/{service => api}/listener_test.go | 2 +- internal/server/{service => api}/swagger.go | 2 +- .../server/{service => api}/swagger_test.go | 8 +- .../observability/prometheus/prometheus.md | 2 +- .../serviceconfig/queue/clientsync/config.go | 2 + .../queue/documentclean/config.go | 2 + .../queue/documentinit/config.go | 2 + .../queue/documentsync/config.go | 2 + .../queue/documenttext/config.go | 2 + internal/serviceconfig/queue/query/config.go | 2 + .../serviceconfig/queue/querysync/config.go | 2 + .../queue/queryversionsync/config.go | 2 + internal/test/{service.go => api.go} | 44 +- .../test/{service_test.go => api_test.go} | 12 +- internal/test/container.go | 17 +- internal/test/container_test.go | 10 +- internal/test/ecosystem.go | 300 ++----- internal/test/ecosystem_test.go | 68 +- internal/test/objectstore.go | 8 +- internal/test/objectstore_test.go | 3 +- internal/test/queryAPI/service.go | 59 ++ internal/test/queryAPI/service_test.go | 80 ++ internal/test/queryService/service.go | 29 - internal/test/queryService/service_test.go | 62 -- internal/test/queue.go | 11 + internal/test/queue_test.go | 16 + internal/test/runner.go | 136 ++- internal/test/runner_test.go | 24 +- .../mock_ClientInterface.go | 484 +++++----- .../mock_ClientWithResponsesInterface.go | 610 +++++++------ pkg/{queryService => queryAPI}/api.gen.go | 140 ++- scripts/database.yml | 7 + scripts/openapi-scripts.yml | 8 +- .../{queryService.yaml => queryAPI.yaml} | 96 +- test/process_test.go | 116 +-- .../accessory_test.go | 10 +- .../{queryService => queryAPI}/client_test.go | 16 +- .../collectorservice_test.go | 28 +- test/queryAPI/exportservice_test.go | 27 + .../queryservice_test.go | 30 +- test/queryService/exportservice_test.go | 31 - 105 files changed, 3276 insertions(+), 2484 deletions(-) rename api/{queryService => queryAPI}/api.gen.go (79%) rename api/{queryService => queryAPI}/client.go (89%) rename api/{queryService => queryAPI}/client_test.go (88%) rename api/{queryService => queryAPI}/collector.go (96%) rename api/{queryService => queryAPI}/collector_test.go (91%) rename api/{queryService => queryAPI}/controllers.go (95%) rename api/{queryService => queryAPI}/controllers_test.go (52%) create mode 100644 api/queryAPI/documents.go create mode 100644 api/queryAPI/documents_test.go rename api/{queryService => queryAPI}/export.go (50%) rename api/{queryService => queryAPI}/export_test.go (79%) rename api/{queryService => queryAPI}/parse.go (99%) rename api/{queryService => queryAPI}/parse_test.go (99%) rename api/{queryService => queryAPI}/query.go (90%) rename api/{queryService => queryAPI}/query_test.go (89%) rename api/{queryService => queryAPI}/status.go (78%) rename api/{queryService => queryAPI}/status_test.go (83%) delete mode 100644 api/queryService/documents.go delete mode 100644 api/queryService/documents_test.go rename cmd/{queryService => queryAPI}/main.go (85%) rename database/migrations/{00000000000102_job_views.down.sql => 00000000000102_document_views.down.sql} (100%) create mode 100644 database/migrations/00000000000102_document_views.up.sql delete mode 100644 database/migrations/00000000000102_job_views.up.sql delete mode 100644 internal/database/repository/job_test.go create mode 100644 internal/database/repository/sync_test.go rename internal/server/{service => api}/listener.go (99%) rename internal/server/{service => api}/listener_test.go (99%) rename internal/server/{service => api}/swagger.go (97%) rename internal/server/{service => api}/swagger_test.go (86%) rename internal/test/{service.go => api.go} (51%) rename internal/test/{service_test.go => api_test.go} (71%) create mode 100644 internal/test/queryAPI/service.go create mode 100644 internal/test/queryAPI/service_test.go delete mode 100644 internal/test/queryService/service.go delete mode 100644 internal/test/queryService/service_test.go rename mocks/{queryservice => queryapi}/mock_ClientInterface.go (71%) rename mocks/{queryservice => queryapi}/mock_ClientWithResponsesInterface.go (65%) rename pkg/{queryService => queryAPI}/api.gen.go (94%) rename serviceAPIs/{queryService.yaml => queryAPI.yaml} (92%) rename test/{queryService => queryAPI}/accessory_test.go (76%) rename test/{queryService => queryAPI}/client_test.go (71%) rename test/{queryService => queryAPI}/collectorservice_test.go (77%) create mode 100644 test/queryAPI/exportservice_test.go rename test/{queryService => queryAPI}/queryservice_test.go (72%) delete mode 100644 test/queryService/exportservice_test.go diff --git a/.mockery.yml b/.mockery.yml index 2d14758f..b0261908 100644 --- a/.mockery.yml +++ b/.mockery.yml @@ -12,7 +12,7 @@ packages: queryorchestration/internal/server/runner: interfaces: Controller: - queryorchestration/pkg/queryService: + queryorchestration/pkg/queryAPI: interfaces: ClientWithResponsesInterface: ClientInterface: diff --git a/README.md b/README.md index 7815b9ea..d7d74fc0 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,21 @@ This repository contains the DoczyAI code. -Using the following project as a baseline: https://github.com/golang-standards/project-layout. +Using the following project as a baseline: `https://github.com/golang-standards/project-layout`. ## Installation and Usage - Install devbox: `https://www.jetify.com/docs/devbox/installing_devbox` - Ubuntu/MacOS: `curl -fsSL https://get.jetify.com/devbox | bash` + - NixOS: `devbox` - Install docker: `https://docs.docker.com/engine/install/` - (IF NECESSARY) Ensure user in docker group and docker group is in sudo group - ``` + + ```sh sudo groupadd docker sudo usermod -aG docker $USER ``` + - Run `touch .env` to create `.env` file for custom environment variables - Run `devbox shell` to enter the environment - Run `task fullsuite` to run all tests that ensure the current state @@ -54,14 +57,14 @@ This will: **Service** - This term is used internally in order to refer to commands that get deployed as APIs. **Runner** - This term is used internally in order to refer to commands that get deployed as consumers of a queue. -### Creating a new Service +### Creating a new API -1. Add a file named `.yml`. The service name is important, as it will be used as a reference throughout the codebase. The service name must be in the format `Service`. E.g. queryService, ClientService +1. Add a file named `.yml`. The api name is important, as it will be used as a reference throughout the codebase. The api name must be in the format `API`. E.g. queryAPI, ClientAPI 2. Run `task openapi:generate`. This will generate the following: - - A location to implement the server-side functions in `./api//`, as well as generated functions, models and swagger docs. - - A location with the client-side code in `./pkg//` -3. Implement the controllers in `./api//` -4. Create a command in `./cmd//main.go` which creates a new instance from `./internal/api` + a. A location to implement the server-side functions in `./api//`, as well as generated functions, models and swagger docs. + b. A location with the client-side code in `./pkg//` +3. Implement the controllers in `./api//` +4. Create a command in `./cmd//main.go` which creates a new instance from `./internal/api` ### Creating a new Runner diff --git a/api/docCleanRunner/runner_test.go b/api/docCleanRunner/runner_test.go index eef10d3b..a36fbd83 100644 --- a/api/docCleanRunner/runner_test.go +++ b/api/docCleanRunner/runner_test.go @@ -67,7 +67,7 @@ func TestDocCleanRunner(t *testing.T) { Body: &body, } - doc := document.Document{ + doc := document.DocumentSummary{ ID: bod.ID, ClientID: uuid.New(), Hash: "example_hash", @@ -82,7 +82,7 @@ func TestDocCleanRunner(t *testing.T) { pgxmock.NewRows([]string{"isclean"}). AddRow(false), ) - pool.ExpectQuery("name: GetDocument :one").WithArgs(dbid). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(dbid). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(dbid, database.MustToDBUUID(doc.ClientID), doc.Hash), diff --git a/api/docInitRunner/runner_test.go b/api/docInitRunner/runner_test.go index 5fa7c0a0..108a7b12 100644 --- a/api/docInitRunner/runner_test.go +++ b/api/docInitRunner/runner_test.go @@ -51,7 +51,7 @@ func TestDocInitRunner(t *testing.T) { clientId := uuid.New() bucketName := "bucketName" location := fmt.Sprintf("%s/aaa", clientId) - docinfo := document.Document{ + docinfo := document.DocumentSummary{ ID: uuid.New(), ClientID: clientId, Hash: "example_hash", @@ -91,7 +91,7 @@ func TestDocInitRunner(t *testing.T) { pool.ExpectExec("name: AddDocumentEntry :exec").WithArgs(database.MustToDBUUID(docinfo.ID), bucketName, location). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(docinfo.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(docinfo.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(docinfo.ID), database.MustToDBUUID(docinfo.ClientID), "example"), @@ -144,7 +144,7 @@ func TestProcessRecord(t *testing.T) { } bucketName := "bucketName" location := fmt.Sprintf("%s/aaa", j.ID.String()) - docinfo := document.Document{ + docinfo := document.DocumentSummary{ ID: uuid.New(), ClientID: j.ID, Hash: "example_hash", @@ -174,7 +174,7 @@ func TestProcessRecord(t *testing.T) { pool.ExpectExec("name: AddDocumentEntry :exec").WithArgs(database.MustToDBUUID(docinfo.ID), bucketName, location). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(docinfo.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(docinfo.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(docinfo.ID), database.MustToDBUUID(docinfo.ClientID), "example"), diff --git a/api/docSyncRunner/runner_test.go b/api/docSyncRunner/runner_test.go index 1f28d3c5..ad2b6969 100644 --- a/api/docSyncRunner/runner_test.go +++ b/api/docSyncRunner/runner_test.go @@ -55,7 +55,7 @@ func TestDocInitRunner(t *testing.T) { j := client.Client{ ID: uuid.New(), } - docinfo := document.Document{ + docinfo := document.DocumentSummary{ ID: uuid.New(), ClientID: j.ID, } @@ -69,7 +69,7 @@ func TestDocInitRunner(t *testing.T) { Body: &body, } - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(docinfo.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(docinfo.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(docinfo.ID), database.MustToDBUUID(docinfo.ClientID), "example"), diff --git a/api/docTextRunner/runner_test.go b/api/docTextRunner/runner_test.go index 2a0943df..2880e073 100644 --- a/api/docTextRunner/runner_test.go +++ b/api/docTextRunner/runner_test.go @@ -82,8 +82,11 @@ func TestDocCleanRunner(t *testing.T) { pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "mimetype", "fail"}). AddRow(cleanId, database.MustToDBUUID(doc.ID), &inloc.Bucket, &inloc.Key, int64(1), dbmimetype, repository.NullCleanfailtype{}), ) - pool.ExpectExec("name: AddDocumentTextEntry :exec").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, cleanId). - WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectQuery("name: AddDocumentTextEntry :one").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, cleanId). + WillReturnRows( + pgxmock.NewRows([]string{"id"}). + AddRow(database.MustToDBUUID(uuid.New())), + ) mockSQS.EXPECT(). SendMessage( diff --git a/api/queryService/api.gen.go b/api/queryAPI/api.gen.go similarity index 79% rename from api/queryService/api.gen.go rename to api/queryAPI/api.gen.go index da88e348..3bd99e92 100644 --- a/api/queryService/api.gen.go +++ b/api/queryAPI/api.gen.go @@ -1,7 +1,7 @@ -// Package queryservice provides primitives to interact with the openapi HTTP API. +// Package queryapi provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version 2.4.1 DO NOT EDIT. -package queryservice +package queryapi import ( "bytes" @@ -172,19 +172,31 @@ type DocClient struct { // Document The document properties. type Document struct { - // Bucket The bucket containing the document - Bucket string `json:"bucket"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` + + // Fields The fields and the value for the document + Fields map[string]interface{} `json:"fields"` + + // Hash The document hash + Hash Hash `json:"hash"` // Id The document id. Id DocumentID `json:"id"` - - // Key The path to the document - Key string `json:"key"` } // DocumentID The document id. type DocumentID = openapi_types.UUID +// DocumentSummary The document properties. +type DocumentSummary struct { + // Hash The document hash + Hash Hash `json:"hash"` + + // Id The document id. + Id DocumentID `json:"id"` +} + // ExportDetails Payload for export trigger response. type ExportDetails struct { // ClientId The client external id @@ -233,6 +245,9 @@ type FieldFilter struct { // FieldFilterCondition The possible field filtering conditions. type FieldFilterCondition string +// Hash The document hash +type Hash = string + // IdMessage A single uuid. type IdMessage struct { // Id Unique identifier for entity. @@ -240,7 +255,7 @@ type IdMessage struct { } // ListDocuments The documents in the client. -type ListDocuments = []Document +type ListDocuments = []DocumentSummary // ListQueries A set of queries. type ListQueries struct { @@ -370,6 +385,9 @@ type ServerInterface interface { // Get client sync status // (GET /client/{id}/status) GetStatusByClientId(ctx echo.Context, id ClientID) error + // Get document details by its id + // (GET /document/{id}) + GetDocument(ctx echo.Context, id DocumentID) error // Check export state. // (GET /export/{id}) ExportState(ctx echo.Context, id ExportID) error @@ -417,6 +435,8 @@ func (w *ServerInterfaceWrapper) GetClient(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) } + ctx.Set(PlaceholderAuthScopes, []string{}) + // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetClient(ctx, id) return err @@ -530,6 +550,24 @@ func (w *ServerInterfaceWrapper) GetStatusByClientId(ctx echo.Context) error { return err } +// GetDocument converts echo context to params. +func (w *ServerInterfaceWrapper) GetDocument(ctx echo.Context) error { + var err error + // ------------- Path parameter "id" ------------- + var id DocumentID + + err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) + } + + ctx.Set(PlaceholderAuthScopes, []string{}) + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetDocument(ctx, id) + return err +} + // ExportState converts echo context to params. func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error { var err error @@ -660,6 +698,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.GET(baseURL+"/client/:id/documents", wrapper.ListDocumentsByClientId) router.POST(baseURL+"/client/:id/export", wrapper.TriggerExport) router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId) + router.GET(baseURL+"/document/:id", wrapper.GetDocument) router.GET(baseURL+"/export/:id", wrapper.ExportState) router.GET(baseURL+"/query", wrapper.ListQueries) router.POST(baseURL+"/query", wrapper.CreateQuery) @@ -672,60 +711,63 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xbaXMjt9H+Kyi8/mbeh0jprXyQpbWLyUa7WWlTTnYVFjjTJGEPZygAI4ne4n9P4ZoT", - "Qw654tou5ZsoXI3uBw8a3T1fsBet1lEIoeD44gteAvGBqT8/EAFv6YoK+cMH7jG6FjQK8YVqQoFsQzSc", - "R2xFZAOiIdI/0GesWv//iYZ+9PQXQVfQ1H9/xriB4Zms1gHgC9ztdGynsw5uYO4tYUXkiivy/BbChVji", - "i36vgddECGBy8f986jTP77+3w/Sv73ADi81aTskFo+ECb7dbOYqRFQizo6uAQigm1+UN3S0BeaoVTa5b", - "uIGp/O+aiCVu4JCs5LzUxw3M4CGmDHx8IVgMWXm/YzDHF/j/2qlC27qVt5OFpUxvntcRq5QCVOtJpEgW", - "llL8Iwa2qRJico2iORJLQA+y28uLYldXRmLA11HIQdloEkozk+ANYxErS2ebEQf2CAyB7CblqwKuSwrT", - "t512VHJMwkcSUP8DPMTAhWtt1Y6Y7oBmkb95kaW3Vm0ZlF6R8HYTeg4ptGEMWilHJAiiJxouEPEEfQTE", - "N6HH0+Mwi6IASIi3DTszAyLAbfg1i9bABAUuTzLyZFcahXKXaZMcSv36mLeAqdP/RvbUoLC4+qSBpua4", - "T7YVzX4BT6S72nOq4dngRs2V8s/l5SVu5LjmLMc1LRezpGv+EPmbnetS/+t0V9ZEtQpujJYrhVEqzO+e", - "gYC8AnrDAzRwK4iIeXnR2zV4dC5hJLHKVS9JKcSIIpUCYbySe5rcTG//dXOFG/jm3Z3688115sfk5qfM", - "nt0CuM1wafdt1s9eVVp3ZdvwZEP77WM2X7SRmaLaTh/3YJVajotD+hBDEbKd7vlwPOx7zfHc95ujkec3", - "Z/0zr9kbDnuD7sz3/X4fN7DeK77AcawmKGC8Qp8f134dchBLItCKbNAMUKyGOHDukXDKDYft16YlvOPo", - "oqzqyId/AuNKfNdufODSYsiLfECPumcrqzcairOBVhxdSaie93r9/qjX6Z+Nh4PR6KzT6TTwioa6tZsI", - "Ie23AKalCALwhOsmS5rQKvIhKKtP0/n0Md3ELn3YvW4bWMNoehhFzykE/n7gW6F/1N23DRwQAVwcIabR", - "3NST1xOwujNkDZuZRcCzOGqKwulNlZfopFrUiuVLSmkUjekkh5xu3aBVEhVvaeUO2MFlHNU6Tbm19alq", - "YOX81cBR6s3ldWnum2Sa/buuvsKiWKxjYRQgJ27tvrY+keZvl81/31fcXgUcVytbXhtlDVMBqwMPiwIr", - "eZ7okUpcIxZhjGxyUt2Cw/18TzZBRHxlcsW5yudDV9WWP5pBjiaDP86ZLgHtOvI03+293Ap+ygtdaqf1", - "mBs4rrvAR7dfqWdo2EOb7PPerct4ValK37RmdFrW4yz2foWKCXQb8qJQEBpKmIvMtEe5q/uVY/ek9f8r", - "VPj18gmMRLRLos5gXBCp7ZTKZQOjFi3ALtVX+ZCJ8vXLo+A2dvx5c9afj5uj/mDcPCezbrMLw+GsP++O", - "wR8d4TbqoMI1CEIDvpu0TGhDMLpYAEP22e84Y8c4MPqCmAaRR0Sl02dbJak/Lam3VHY0gv1G12hOA0BP", - "NAikZzuP4rCgRd6/aLfJzGtfXrZ7nd6w0+v220q1I+I1O6P+rDnqnI+b40HvrDkj/vmoMx9756NBy+OP", - "e3Ci5lZgaaug1pfxtt36/vNnOdQJ6nqPFW2hisdK1t3Z8XCpFbOqQBw0B/6w2xx1+17zfAzQHJwNYNwf", - "d7vzbv9oxFW9PNUZjTinsyARTG5Mc5B9c0o1BSDAV5Gt6ZpFCwZcunpzQgPwnS9OvfCdhu9uqBuMqxs6", - "NGKUca6u2emcBjZAmZ/wR9WgX9BetAY0Ixx8FIXGCzIu0SMJYr27Wl6Juqz11DVcEhougEt5jhEzGYzS", - "OGxZCxD60+pHZ0C4QLJZXsvJhLmHmmxtCroqBDL6PfeRYaJyOcrRnLIXXLDsiLhck6xJKtSrfT0vCuJV", - "WObLKPSpqOEkZRa6SsZYf296/ENBQ9BtQN2GYg7zOLA3pwZTDrOH3+kpdLvyJZ6HboHnMjtsZPSViH6/", - "2yxXWQ3vIBx9MOeJyZKVcuwTAOdTsSRy/YWKxjL70wsiDv5UhYAeSYAbOFpDmP0dwFxMy90YXSxd/6eh", - "F8S+Dvvpv1zUNvH/DpyTBbiiaJyGiwCQpOeqYGZ+yEcbt4JQ0DkFpq//UFCxaR3M+PVCoG8pF9Y34rtd", - "o/RJl/j4tZgz8Xr306aURr6KqetUXCIOQrLLg+5RVupD1VA5b2FkLdHVCz0v97Db23NmrBQudesJHVsL", - "ogX1UBxSJSc8gxe7MwjHh7eicE4XtXZ8pbvW8v+TIMZXhLSs9qYZA+4a+sH0N2urJ7RWdQ1Z72RH5yNC", - "TVGKOZX2VWnXq0TDxZCl/H/MtAttQ09JinCXb/v58xfpym6dRK4X3ZWWStwHZDcrbxKVngJEUhFK9+Lh", - "SPn9bahGVxqnyglXOqh+9cH8bNgcnY3OmmMfzpvng0F/SM77/f6IHOGDa+GBi8pkqSObaOyEJAhtErVs", - "NMvS00Of7DrMeOihLeg+u3pxykqTaEXo16xbE/ati+YsWuUUUVaA8kgcNRfA40Dk8vLJBLujD/tDD3rJ", - "6v0ZOO/K8cmRpaIB6/D89fbdzfTNz3cfLq/u3n3ADXz17ubuzc930x8/vn3rdEjUuscno7J4+72vnq8n", - "FNebodSr0ldIGFNjZnJ9oNugT9ceh6dWqq0iy9bvZbNsve5gNBj3zwajTHKtU06uyccceDGjYnMrxdWK", - "XQfEg2UU+MAuY3keSq/0tAOy45HaLyjQzGMRM0BU8qckAmLeCar+RVdvpBUwPzcv30+af4NNesLImsrf", - "qqiDhvPI4SO9nySuaP4mVepG75i3BC7MLcuBPVJPu3qCCkXqrn6X7yfyNWPNgDutTqur4mJrCMma4gvc", - "b3VafazIYamU1faSgPg6cpG4vpM5IiiEJ5uefqJCh83WLHqkPvjI19G/ln6taIEmfjLehN31SQAubLbe", - "i0JhlifrdUB1aK79C9c4OqS0yjgPSusu/Cn53L6Dl5UurWQq1iX1Ot0XltlUjzhk1u1GRB/x2POA83kc", - "BJsXKnUadDpVI5Jdtwv1UNsGHtYblq3gyp5TfPHJcUI/3W/vG5jHqxWRTwoDmhzmJPbJgsurxJRe6FOB", - "7+X0BsbtL9TfSvEWrrzCBxCMwqMCM9c3l2cRPdsgKripucsj+CcQGfjm8NB5MTykqalqMGTO2J/P/olt", - "fwKRHDmp9sn1DtPmyzc/uddNu2SyAfeK5DwH/WuXguuoLOUqh5rlNYm5SjrTg78BnRnHZw+dici4OzXI", - "q+Mgd71t6zG9MpbRKs7yf02GaXvZmp4DuCap9zF0k6s3LrOO7f7DxuDaPyUFpYVKLgpKRP9Ts9BB+DBM", - "lTVaYrAsWNKSjVPS1i0Iu3wq0n7Cuq3G0QmoK1u9sp+6ZqDCoM4Cpn1sNthVTidnfWVkdpsH6258FvnM", - "z0bN9/CZtFRg3pVpOH22yZakuwgtF53/NoyWTwjscKySbciNvQKwqLiAyOVDdLSkdBMm6nsRciviTmfF", - "1ePzK/gycn+pQQVVfl6mvGPNIskJZXCajL5O75+IHPO1AxXsaAQ17Kc03/qmD9M0DeiQ8E2ufOf1eYzG", - "eGlBR+akmJqUSo5NK3VqECzfhJ79ZqGWr2g+gvg2jmLxs4tqZjVbeF0+o/3kJLXhaV64EmEahrvjHldL", - "8H7VuPJixqxdVKw+V5qUR1VaZAWnRFO+erCadJaEoxlAiJLCrdcQCJOmy9WwtXZQzqFYSr8GVVh6sAn9", - "vS/aIF+DkK1KU4VgHqMCGCVuL9BWRZzY87PLOCB1WdzBa/H5HhLVWwypREIOQjXSADqNdHAWQFeMnMa7", - "yhYQHJMDeMjI9gfwtHR+53/h/6fEMBWATYjriNi/hvHu0H+K2RNRlanLqoLAawu3JTbJxdjKLHXQRZck", - "sQ/LCmRorkZS4OTstjsloIP4ttbWxtRs3j0pgzgiS6CB+NqTBAfxUFuYiqivwKnzHn6jqikVjekaqjjU", - "H6tVXcn5svtC1AO4ODlqsyViFdAt1IQdEvjonEJYU8blklbLyOPgNYQJ1W73I1/Nyx4txgvFNizyYy+p", - "Y1GlMzEL8AVeCrHmF+22H3m/bVpetGo/dhXyzTrFmd5Z7EoPLlBcJB049R7maUFO/oG9bdScxgbJszMV", - "A+d1J0vD6clcpThq3blSj93MlNN+3Vn0CzIzS/7puL3f/jcAAP//x4FEowZKAAA=", + "H4sIAAAAAAAC/+xbW3PjNrL+KyycvEUX6mbJOnUeFHuS6OysZzL2bGV3xquCyJaELEXKAGiPMqX/voUb", + "r6BEydYktd4qP1giCDS6P3zd6G59RV603kQhhJyh8Ve0AuwDlf9+wBzekjXh4oMPzKNkw0kUorF85ATi", + "mUPCRUTXWDxwSOioD85nJJ/+7xMJ/ejp/zhZQ1P9/xmhBoIveL0JAI1Rx3XNoAsXNRDzVrDGYsU1/vIW", + "wiVfoXGv20AbzDlQsfg/P7nNy/vvzWvq03eogfh2I6ZknJJwiXa7nXiL4jVwvaOrgEDIp9flDd2twPHk", + "U2d63UINRMS3G8xXqIFCvBbzEh81EIWHmFDw0ZjTGLLyfkdhgcbof9qpQtvqKWsnCwuZriMvXu+Rw9fP", + "zyJJZnEhy5svm4hWSgLy6VnkSBYWUvwSA91WCTG9dqKFw1fgPIhhLy+KWV0ChgLbRCEDiZdpKCCHgzeU", + "RrQsnXnsMKCPQB0Qw4R8VYfIJoUe204HSjmm4SMOiP8BHmJg3La2fO5QNcCZR/72RZbeGbVlTswVDm+3", + "oWeRQhlGnxzCHBwE0RMJlw72OHkEh21Dj6VHcx5FAeAQ7RpmZgqYg93wGxptgHICTLCK44mhJArFLtNH", + "4lXi1z9/BjB1xt+IkQoUBlefFNDkHPfJtqL5b+DxdFcHGAa+aNzIuVIunEwmqJHjvYsc77VsLJeu+UPk", + "b/euS/zn6a6siWoV3GgtVwojVZjfPQUOeQV0B0do4JZjHrPyorcb8MhCwEhglclRglKwFkUoBcJ4LfY0", + "vZnd/v3mCjXQzbs7+e+b68yH6c1PmT3bBbCbYWL2rdfPuk2lu7JtWLKhw/bRmy/aSE9RbaePB7BKDMfF", + "IXmIoQhZt3M5GA16XnO08P3mcOj5zXnvwmt2B4NuvzP3fb/XQw2k9orGKI7lBAWMV+jz48avQw58hbmz", + "xltnDk4sX7Hg3MPhjGkOO6xNQ3in0UVZ1ZEPfwPKpPhWlw9MWMzxIh+cRzWyldUbCflFXymOrAVUL7vd", + "Xm/YdXsXo0F/OLxwXbeB1iRUTzuJEMJ+S6BKiiAAj9s8WfLIWUc+BGX1KTqfPaab2KcPs9ddAykYzY6j", + "6AWBwD8MfCP0j2r4roECzIHxE8TUmpt5wj0BrTtD1rCZWTh84SdNUTi9qfISnVSLWrF8SSmNojGt5JDT", + "rR20UqKil5bhgHm5jKNapym3tjpVDSSDvxo4SqO5vC61v0mmObzrahcWxXwTc60AMXFrv9v6hJu/T5r/", + "uK/wXgUcVytbuI2yhgmH9ZGHRYIVf5mqN6W4WixMKd7mpLoFS/j5Hm+DCPvS5JJzZcznXFVb/mQGOZkM", + "/jxnugS068hTfHfQuRXilBdyaueNmBsorrvAR3tcqWZomEOb7PPerkt5oz1wmU41Z9Hj85wU9n0ilsTB", + "+8y06gpaeZJx6Muj/IiDGBLqNOJmg6yvRtptJ+EN9Vq6kW0Xjfvd9GPPrG++6Ev2BcbB10Ju0Vh/oSfb", + "paMHaPyp0+g2evc29K4wWx3S1M9iTC2kFTISJSRknaBcOVH9PjQcTK6oy1AhknX9RXPeW4yaw15/1LzE", + "806zA4PBvLfojMAfnhDJGnlu4/Ua0+0zQPpttS5XsylYJW6ugWMSsP2OQaePOCXLJVDHpFZe6PwpJzwL", + "Ig/zysDaPBWO82lFvJU8ZVqw38nGWZAAnCcSBOL2sIjisAAL1hu323jutSeTdtftDtxup9eWWBlir+kO", + "e/Pm0L0cNUf97kVzjv3LobsYeZfDfstjj4WowO2PcmGBnLv1vfiTScyvo1279f3nz+JVa6RQ70KoLFRx", + "Icyepj2Xw1p5wYojBM2+P+g0h52e17wcATT7F30Y9UadzqJzymUwtx+7v4wYI/MgEUxsTB0hc68XagqA", + "gy+zh7MNjZYUmAinF5gE4Ftv9WrhOwXf/VDXGJdRUKjFKONc8tZsQQKTkM5P+KN8oLIUXrQBZ44Z+E4U", + "6khTh52SrVntyE8GRGrqGmEfCZfAhDyniJm87KR597IWIPRn1Rf7ADPuiMci9EkmzF2GxdMmJ+tCsqjX", + "tR8ZyiuXI8xZEPqCC5bdpc2BZk1SoV4VT3tREK/DMl9GoYo4jrD9VfKOiV1mp1/GFATtBlTPnJjBIg4c", + "HkmgKDDlMHt8mi+Fbsd1i9At8Fxmh42MvhLR7/eb5Sqr4T2Eow7mIjFZslKOfQJgbMZXWKy/lBlvaj56", + "QcTAn8k02yMOUANFGwiznwNY8Fl5GCXLle17EnpB7KvUqvrPRm0/62BiTyyiY619DqzCTlP/r8AYXoIt", + "DcpIuAzAEdxflY3Ov/LRJB4h5GRBgKrYIuSEb1tHu5N6Oey3hHETIbH9ekrv5MklrRYtFwPDw9QshPol", + "BkpsJ2/iMOCCwR7UiLJuH6peFfMW3qy1A5lpycs96HQPnEsjhU3rakLL1oJoSTwnDomUE76AF9srQaen", + "KaNwQZa1dnylhtaKspNk1DNSk0Z7s4wB9736QY/Xa8tUiFJ1DVnvxEDrhUBOUcodlvZVaderRMPF1LP4", + "PqYqTDf34KTUu49+Pn/+KsLlnZWE1KL7yotJiOKYzQpvJcuM4OBUhJLvPR4pf7wN5duVxqkK9KUOqq/K", + "sLgYNIcXw4vmyIfL5mW/3xvgy16vN8QnxPlKeGC8suhtqQprOzkChKYYXjaaIevZcRdjky4+9tAWdJ9d", + "vThlpUmUItSN2a4Jc592FjRa5xRRVoDK8JT7eIDFAc/1VyQTHO34C7tWS1bvT8N5X61WvFlq/jBB1f/f", + "vruZvfn17sPk6u7dB9RAV+9u7t78ejf78ePbt9agR657elExi7c/2vU8n1Bs95LSqMpYIWFMhZnp9ZFh", + "gzpdBwKeWiXTimppr5utlnY7/WF/1LvoDzNFUrdcJBUXRvBiSvj2VoirFLsJsAerKPCBTmJuiZvfpwMc", + "874j96syu4uYxxQcIvhTEAHWdxHZx6S6cNJOpl+bk/fT5l9gm54wvCHis2zOIeEissRI76dJRJr3pFLd", + "zjvqrYBx7WUZ0EfiqVCPEy5J3TZu8n4qbkzGDMhtua2OzL1tIMQbgsao13JbPSTJYSWV1faSwsYmspG4", + "8snMwU4IT6bN4IlwlZrb0OiR+OA7vsowttSNSAk09ZP3dflEnQRg3HRdeFHI9fJ4swmISv+1f2MKR8e0", + "6+ngQWrdhj8pnz128LLSpR1pxf6yrtt5YZl1F5BFZvVci+g7LPY8YGwRB8H2hVrW+q5b9Uay63ahr23X", + "QIN6r2U78bLnFI0/WU7op/vdfQMxk3TXoMlhTmAfL5lwJbqFRp0KdC+m1zBufyX+Toi3tFVBPwCnBB4l", + "mJnyXJ5B9HzrEM5072QewT8Bz8A3hwf3xfCQlhirwZA5Y//h9v8JeHIshWmm13vMn28b/mSXLR2SqUrc", + "SyL0LC5ChR1MZYcJk/XyLPcJXFZSnnr5G1CeDo4OUB6PdEhUg+BciwNQ2zZR1StjIqXirI+oyUJtL9u/", + "dQQfJb1dmpJyfe5lZjLDf9hqXPvnpKm0Kc1GU4nor46pskZLDJYFS9qec07augVulk9FOkxYt9U4OgN1", + "ZTuVDlPXHGSq1NqsdojN+vtaJ8Wsr4zMbvNg3Y/PIp/52QT7AT4Tlgr03TPNvM+32Z8f2Agtl8j/NoyW", + "rx3sCb6SbYiNvQKwyNwBz5VOVEal5AkT9b0IuRVxp6rz8oL6DL6M7L/KIZzIOC/TZrKhkeCEMjh1Z4Fq", + "MzgTOeZ7GCrYUQuq2U9qvvVNL69pxdAi4ZtcG9Hrixi18dLGksxJ0b0xlRybdgzVIFi2DT3z+5RasaL+", + "wcu3CRSLP7GpZla9hdcVM5qfF6U2PM8NVyDMEHjd7AjPRGCyoTlpMtAwUxWmEr6u027Yc+ZJ1BoWPJln", + "rwxKfmHbqZVe1kdnS20SV4re9qPqagXevxSkvJhSc95lnSjXepdHU9pECOdEU747ttqZrTBz5gChkzQm", + "voYkrDBdrkeztceVHYum9BflEksPppnkYKYkyPe/ZLsuZaOjRwkHSrD9dmE6cs58ozDLWCA1Ke7gtdwl", + "HhLVGwzJItbk/VTBp0b5SZUvj64+qU6l80Ts2caVU2pPDxnZ/gTRu6or/rfs9JQYxgLWhLBOqDcpCO8v", + "N6V4PRNF6V7AKvO/tvRtYpNczjbPTkc5t6Rp4rgKU4beahSYzs5q+8tLqiBk+seTX8TpPo+k7eaEipMC", + "4WsvONXmnzbX3XfPwKjV976RnbuSvlS/Xhyq+2CVG87/jKSQPQPGz47YbDtiBWwL/YfHJNDccwirWwZt", + "0ioZWRy8hnSz3O1+1Ms56aPBd6Gpi0Z+7CX9UrJFK6YBGqMV5xs2brf9yPt92/KidfuxI1Gv1yjO9M7g", + "VkRsgeQgEbDJnApLG7/ySZpdo+Y0ptCSnalYfKk7WVqSSeYq3fPrzpVG53qmRPN1Z1A3xcwM+Svi7n73", + "7wAAAP//OVAUyb5OAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/queryService/client.go b/api/queryAPI/client.go similarity index 89% rename from api/queryService/client.go rename to api/queryAPI/client.go index 36a28961..65713ed3 100644 --- a/api/queryService/client.go +++ b/api/queryAPI/client.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "fmt" @@ -28,7 +28,7 @@ func (s *Controllers) CreateClient(ctx echo.Context) error { }) } -func (s *Controllers) GetClient(ctx echo.Context, id string) error { +func (s *Controllers) GetClient(ctx echo.Context, id ClientID) error { client, err := s.svc.Client.GetByExternalId(ctx.Request().Context(), id) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to get client: %s", err)) @@ -42,7 +42,7 @@ func (s *Controllers) GetClient(ctx echo.Context, id string) error { }) } -func (s *Controllers) UpdateClient(ctx echo.Context, id string) error { +func (s *Controllers) UpdateClient(ctx echo.Context, id ClientID) error { req := ClientUpdate{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) diff --git a/api/queryService/client_test.go b/api/queryAPI/client_test.go similarity index 88% rename from api/queryService/client_test.go rename to api/queryAPI/client_test.go index cfdd9163..e4f1d967 100644 --- a/api/queryService/client_test.go +++ b/api/queryAPI/client_test.go @@ -1,4 +1,4 @@ -package queryservice_test +package queryapi_test import ( "encoding/json" @@ -8,7 +8,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/client" "queryorchestration/internal/database" "queryorchestration/internal/database/repository" @@ -30,11 +30,11 @@ func TestCreateClient(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Client: client.New(cfg), }) - body := queryservice.ClientCreate{ + body := queryapi.ClientCreate{ Name: "example_name", Id: "external_id", } @@ -66,7 +66,7 @@ func TestGetClient(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Client: client.New(cfg), }) @@ -89,10 +89,10 @@ func TestGetClient(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.DocClient + var res queryapi.DocClient err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) - assert.EqualExportedValues(t, queryservice.DocClient{ + assert.EqualExportedValues(t, queryapi.DocClient{ Id: id, Uid: clientUid, Name: "client_name", @@ -108,12 +108,12 @@ func TestUpdateClient(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Client: client.New(cfg), }) cs := false - body := queryservice.ClientUpdate{ + body := queryapi.ClientUpdate{ CanSync: &cs, } bodyBytes, err := json.Marshal(body) diff --git a/api/queryService/collector.go b/api/queryAPI/collector.go similarity index 96% rename from api/queryService/collector.go rename to api/queryAPI/collector.go index 2406ce0d..4eb7b620 100644 --- a/api/queryService/collector.go +++ b/api/queryAPI/collector.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "fmt" @@ -10,7 +10,7 @@ import ( "github.com/labstack/echo/v4" ) -func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId string) error { +func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId ClientID) error { coll, err := s.svc.Collector.GetByClientExternalID(ctx.Request().Context(), clientId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to get collector: %s", err)) @@ -36,7 +36,7 @@ func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId string) }) } -func (s *Controllers) SetCollectorByClientId(ctx echo.Context, clientId string) error { +func (s *Controllers) SetCollectorByClientId(ctx echo.Context, clientId ClientID) error { req := CollectorSet{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) diff --git a/api/queryService/collector_test.go b/api/queryAPI/collector_test.go similarity index 91% rename from api/queryService/collector_test.go rename to api/queryAPI/collector_test.go index 769bae09..996b01af 100644 --- a/api/queryService/collector_test.go +++ b/api/queryAPI/collector_test.go @@ -1,4 +1,4 @@ -package queryservice_test +package queryapi_test import ( "encoding/json" @@ -8,7 +8,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/collector" collectorset "queryorchestration/internal/collector/set" "queryorchestration/internal/database" @@ -49,10 +49,10 @@ func TestSetCollector(t *testing.T) { av := int32(2) cv := int64(1) - body := queryservice.CollectorSet{ + body := queryapi.CollectorSet{ ActiveVersion: &av, MinimumCleanerVersion: &cv, - Fields: &[]queryservice.CollectorField{ + Fields: &[]queryapi.CollectorField{ { Name: "a", QueryId: uuid.New(), @@ -68,7 +68,7 @@ func TestSetCollector(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ CollectorSet: collectorset.New(cfg, &collectorset.Services{ Collector: collector.New(cfg), }), @@ -134,7 +134,7 @@ func TestGetCollectorByclientId(t *testing.T) { ctx := e.NewContext(req, rec) svc := collector.New(cfg) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Collector: svc, }) @@ -156,15 +156,15 @@ func TestGetCollectorByclientId(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.Collector + var res queryapi.Collector err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) - assert.EqualExportedValues(t, queryservice.Collector{ + assert.EqualExportedValues(t, queryapi.Collector{ ClientId: id, MinimumCleanerVersion: coll.MinCleanVersion, MinimumTextVersion: coll.MinTextVersion, ActiveVersion: int32(1), LatestVersion: int32(2), - Fields: []queryservice.CollectorField{}, + Fields: []queryapi.CollectorField{}, }, res) } diff --git a/api/queryService/controllers.go b/api/queryAPI/controllers.go similarity index 95% rename from api/queryService/controllers.go rename to api/queryAPI/controllers.go index eade7a36..26343c33 100644 --- a/api/queryService/controllers.go +++ b/api/queryAPI/controllers.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "queryorchestration/internal/client" @@ -13,7 +13,7 @@ import ( "github.com/go-playground/validator/v10" ) -const Name = "queryService" +const Name = "queryAPI" type Services struct { Export *export.Service diff --git a/api/queryService/controllers_test.go b/api/queryAPI/controllers_test.go similarity index 52% rename from api/queryService/controllers_test.go rename to api/queryAPI/controllers_test.go index 57dd25bb..a32ddf90 100644 --- a/api/queryService/controllers_test.go +++ b/api/queryAPI/controllers_test.go @@ -1,15 +1,15 @@ -package queryservice_test +package queryapi_test import ( "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "github.com/go-playground/validator/v10" "github.com/stretchr/testify/assert" ) func TestNewControllers(t *testing.T) { - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{}) + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{}) assert.NotNil(t, cons) } diff --git a/api/queryAPI/documents.go b/api/queryAPI/documents.go new file mode 100644 index 00000000..bff48154 --- /dev/null +++ b/api/queryAPI/documents.go @@ -0,0 +1,39 @@ +package queryapi + +import ( + "fmt" + "net/http" + + "github.com/labstack/echo/v4" +) + +func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId ClientID) error { + documents, err := s.svc.Document.ListByClientExternalId(ctx.Request().Context(), clientId) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err)) + } + + docs := make([]DocumentSummary, len(documents)) + for i, doc := range documents { + docs[i] = DocumentSummary{ + Id: doc.ID, + Hash: doc.Hash, + } + } + + return ctx.JSON(http.StatusOK, docs) +} + +func (s *Controllers) GetDocument(ctx echo.Context, id DocumentID) error { + document, err := s.svc.Document.GetExternal(ctx.Request().Context(), id) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err)) + } + + return ctx.JSON(http.StatusOK, Document{ + Id: document.Id, + ClientId: document.ClientID, + Hash: document.Hash, + Fields: document.Fields, + }) +} diff --git a/api/queryAPI/documents_test.go b/api/queryAPI/documents_test.go new file mode 100644 index 00000000..b3f23e81 --- /dev/null +++ b/api/queryAPI/documents_test.go @@ -0,0 +1,122 @@ +package queryapi_test + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "testing" + + queryapi "queryorchestration/api/queryAPI" + "queryorchestration/internal/database" + "queryorchestration/internal/database/repository" + "queryorchestration/internal/document" + "queryorchestration/internal/serviceconfig" + "queryorchestration/internal/serviceconfig/queue/clientsync" + queuemock "queryorchestration/mocks/queue" + + "github.com/go-playground/validator/v10" + "github.com/google/uuid" + "github.com/labstack/echo/v4" + "github.com/pashagolub/pgxmock/v3" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestListDocumentsByClientId(t *testing.T) { + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &struct { + serviceconfig.BaseConfig + clientsync.ClientSyncConfig + }{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + mockSQS := queuemock.NewMockSQSClient(t) + cfg.QueueClient = mockSQS + + clientId := "clientid" + + e := echo.New() + req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader("")) + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) + rec := httptest.NewRecorder() + ctx := e.NewContext(req, rec) + + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ + Document: document.New(cfg), + }) + + ctx.Set("id", clientId) + doc := queryapi.ListDocuments{ + { + Id: uuid.New(), + Hash: "hash", + }, + } + + pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId). + WillReturnRows( + pgxmock.NewRows([]string{"id", "hash"}). + AddRow(database.MustToDBUUID(doc[0].Id), "hash"), + ) + + err = cons.ListDocumentsByClientId(ctx, clientId) + assert.NoError(t, err) + assert.Equal(t, http.StatusOK, rec.Code) + + var res queryapi.ListDocuments + err = json.Unmarshal(rec.Body.Bytes(), &res) + assert.NoError(t, err) + assert.EqualExportedValues(t, doc, res) +} + +func TestGetDocument(t *testing.T) { + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &struct { + serviceconfig.BaseConfig + clientsync.ClientSyncConfig + }{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + mockSQS := queuemock.NewMockSQSClient(t) + cfg.QueueClient = mockSQS + + docId := uuid.New() + + e := echo.New() + req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader("")) + req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) + rec := httptest.NewRecorder() + ctx := e.NewContext(req, rec) + + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ + Document: document.New(cfg), + }) + + ctx.Set("id", docId) + doc := queryapi.Document{ + Id: docId, + ClientId: "externalID", + Hash: "example", + Fields: map[string]interface{}{ + "json": "hello", + }, + } + + pool.ExpectQuery("name: GetDocumentExternal :one").WithArgs(database.MustToDBUUID(docId)). + WillReturnRows( + pgxmock.NewRows([]string{"id", "clientId", "hash", "fields"}). + AddRow(database.MustToDBUUID(doc.Id), "externalID", "example", []byte(`{"json": "hello"}`)), + ) + + err = cons.GetDocument(ctx, docId) + assert.NoError(t, err) + assert.Equal(t, http.StatusOK, rec.Code) + + var res queryapi.Document + err = json.Unmarshal(rec.Body.Bytes(), &res) + assert.NoError(t, err) + assert.EqualExportedValues(t, doc, res) +} diff --git a/api/queryService/export.go b/api/queryAPI/export.go similarity index 50% rename from api/queryService/export.go rename to api/queryAPI/export.go index aa0af464..2ebc26d8 100644 --- a/api/queryService/export.go +++ b/api/queryAPI/export.go @@ -1,16 +1,15 @@ -package queryservice +package queryapi import ( "net/http" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) TriggerExport(ctx echo.Context, clientId string) error { +func (s *Controllers) TriggerExport(ctx echo.Context, clientId ClientID) error { return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"}) } -func (s *Controllers) ExportState(ctx echo.Context, id types.UUID) error { +func (s *Controllers) ExportState(ctx echo.Context, id ExportID) error { return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"}) } diff --git a/api/queryService/export_test.go b/api/queryAPI/export_test.go similarity index 79% rename from api/queryService/export_test.go rename to api/queryAPI/export_test.go index b0542607..4393763d 100644 --- a/api/queryService/export_test.go +++ b/api/queryAPI/export_test.go @@ -1,4 +1,4 @@ -package queryservice_test +package queryapi_test import ( "net/http" @@ -6,7 +6,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "github.com/go-playground/validator/v10" "github.com/google/uuid" @@ -20,7 +20,7 @@ func TestTriggerExport(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{}) + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{}) err := cons.TriggerExport(ctx, "clientid") assert.NoError(t, err) @@ -34,7 +34,7 @@ func TestExportState(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{}) + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{}) id := uuid.New() diff --git a/api/queryService/parse.go b/api/queryAPI/parse.go similarity index 99% rename from api/queryService/parse.go rename to api/queryAPI/parse.go index a5343ebb..7a9c5b79 100644 --- a/api/queryService/parse.go +++ b/api/queryAPI/parse.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "errors" diff --git a/api/queryService/parse_test.go b/api/queryAPI/parse_test.go similarity index 99% rename from api/queryService/parse_test.go rename to api/queryAPI/parse_test.go index 80e3beb4..4f780e89 100644 --- a/api/queryService/parse_test.go +++ b/api/queryAPI/parse_test.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "testing" diff --git a/api/queryService/query.go b/api/queryAPI/query.go similarity index 90% rename from api/queryService/query.go rename to api/queryAPI/query.go index e1f65f6c..aca963bc 100644 --- a/api/queryService/query.go +++ b/api/queryAPI/query.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "fmt" @@ -8,7 +8,6 @@ import ( resultprocessor "queryorchestration/internal/query/result/processor" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) func (s *Controllers) ListQueries(ctx echo.Context) error { @@ -27,7 +26,7 @@ func (s *Controllers) ListQueries(ctx echo.Context) error { }) } -func (s *Controllers) GetQuery(ctx echo.Context, id types.UUID) error { +func (s *Controllers) GetQuery(ctx echo.Context, id QueryID) error { query, err := s.svc.Query.Get(ctx.Request().Context(), id) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to get query: %s", err)) @@ -66,7 +65,7 @@ func (s *Controllers) CreateQuery(ctx echo.Context) error { }) } -func (s *Controllers) UpdateQuery(ctx echo.Context, id types.UUID) error { +func (s *Controllers) UpdateQuery(ctx echo.Context, id QueryID) error { req := QueryUpdate{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -85,7 +84,7 @@ func (s *Controllers) UpdateQuery(ctx echo.Context, id types.UUID) error { return ctx.NoContent(http.StatusOK) } -func (s *Controllers) TestQuery(ctx echo.Context, id types.UUID) error { +func (s *Controllers) TestQuery(ctx echo.Context, id QueryID) error { req := QueryTestRequest{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) diff --git a/api/queryService/query_test.go b/api/queryAPI/query_test.go similarity index 89% rename from api/queryService/query_test.go rename to api/queryAPI/query_test.go index 98e2944d..a48820af 100644 --- a/api/queryService/query_test.go +++ b/api/queryAPI/query_test.go @@ -1,4 +1,4 @@ -package queryservice_test +package queryapi_test import ( "encoding/json" @@ -8,7 +8,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/collector" "queryorchestration/internal/database" "queryorchestration/internal/database/repository" @@ -41,12 +41,12 @@ func TestCreateQuery(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Query: query.New(cfg), }) - body := queryservice.QueryCreate{ - Type: queryservice.CONTEXTFULL, + body := queryapi.QueryCreate{ + Type: queryapi.CONTEXTFULL, } bodyBytes, err := json.Marshal(body) assert.NoError(t, err) @@ -85,7 +85,7 @@ func TestListQueries(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Query: query.New(cfg), }) @@ -105,14 +105,14 @@ func TestListQueries(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.ListQueries + var res queryapi.ListQueries err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) assert.NotNil(t, res.Queries) - assert.ElementsMatch(t, res.Queries, []queryservice.Query{ + assert.ElementsMatch(t, res.Queries, []queryapi.Query{ { Id: id, - Type: queryservice.CONTEXTFULL, + Type: queryapi.CONTEXTFULL, ActiveVersion: 1, LatestVersion: 2, }, @@ -126,7 +126,7 @@ func TestGetQuery(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Query: query.New(cfg), }) @@ -148,12 +148,12 @@ func TestGetQuery(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.Query + var res queryapi.Query err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) - assert.EqualExportedValues(t, queryservice.Query{ + assert.EqualExportedValues(t, queryapi.Query{ Id: id, - Type: queryservice.CONTEXTFULL, + Type: queryapi.CONTEXTFULL, ActiveVersion: 1, LatestVersion: 2, }, res) @@ -172,14 +172,14 @@ func TestUpdateQuery(t *testing.T) { cfg.QueueClient = mockSQS cfg.QueryVersionSyncURL = "here" - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ QueryUpdate: queryupdate.New(cfg, &queryupdate.Services{ Query: query.New(cfg), }), }) av := int32(2) - body := queryservice.QueryUpdate{ + body := queryapi.QueryUpdate{ ActiveVersion: &av, } bodyBytes, err := json.Marshal(body) @@ -230,7 +230,7 @@ func TestTestQuery(t *testing.T) { docsvc := document.New(cfg) col := collector.New(cfg) que := query.New(cfg) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Collector: col, Query: que, QueryTest: querytest.New(cfg, &querytest.Services{ @@ -242,7 +242,7 @@ func TestTestQuery(t *testing.T) { }), }) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), } params := &result.Process{ @@ -250,7 +250,7 @@ func TestTestQuery(t *testing.T) { DocumentID: doc.ID, QueryVersion: int32(3), } - body := queryservice.QueryTestRequest{ + body := queryapi.QueryTestRequest{ DocumentId: params.DocumentID, QueryVersion: params.QueryVersion, } @@ -283,10 +283,10 @@ func TestTestQuery(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.QueryTestResponse + var res queryapi.QueryTestResponse err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) - assert.EqualExportedValues(t, queryservice.QueryTestResponse{ + assert.EqualExportedValues(t, queryapi.QueryTestResponse{ Value: "old_value", }, res) } diff --git a/api/queryService/status.go b/api/queryAPI/status.go similarity index 78% rename from api/queryService/status.go rename to api/queryAPI/status.go index fa9a11ae..24e320a3 100644 --- a/api/queryService/status.go +++ b/api/queryAPI/status.go @@ -1,4 +1,4 @@ -package queryservice +package queryapi import ( "fmt" @@ -7,7 +7,7 @@ import ( "github.com/labstack/echo/v4" ) -func (s *Controllers) GetStatusByClientId(ctx echo.Context, id string) error { +func (s *Controllers) GetStatusByClientId(ctx echo.Context, id ClientID) error { status, err := s.svc.Client.GetStatusByExternalId(ctx.Request().Context(), id) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to find client: %s", err)) diff --git a/api/queryService/status_test.go b/api/queryAPI/status_test.go similarity index 83% rename from api/queryService/status_test.go rename to api/queryAPI/status_test.go index 0e058c8e..8ea3fe6a 100644 --- a/api/queryService/status_test.go +++ b/api/queryAPI/status_test.go @@ -1,4 +1,4 @@ -package queryservice_test +package queryapi_test import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/client" "queryorchestration/internal/database" "queryorchestration/internal/database/repository" @@ -28,7 +28,7 @@ func TestGetClientStatus(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ + cons := queryapi.NewControllers(validator.New(), &queryapi.Services{ Client: client.New(cfg), }) @@ -53,10 +53,10 @@ func TestGetClientStatus(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) - var res queryservice.ClientStatusBody + var res queryapi.ClientStatusBody err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) - assert.EqualExportedValues(t, queryservice.ClientStatusBody{ - Status: queryservice.INSYNC, + assert.EqualExportedValues(t, queryapi.ClientStatusBody{ + Status: queryapi.INSYNC, }, res) } diff --git a/api/queryService/documents.go b/api/queryService/documents.go deleted file mode 100644 index 32071136..00000000 --- a/api/queryService/documents.go +++ /dev/null @@ -1,26 +0,0 @@ -package queryservice - -import ( - "fmt" - "net/http" - - "github.com/labstack/echo/v4" -) - -func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId string) error { - documents, err := s.svc.Document.ListByClientExternalId(ctx.Request().Context(), clientId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err)) - } - - docs := make([]Document, len(documents)) - for i, doc := range documents { - docs[i] = Document{ - Id: doc.ID, - Bucket: doc.Bucket, - Key: doc.Key, - } - } - - return ctx.JSON(http.StatusOK, docs) -} diff --git a/api/queryService/documents_test.go b/api/queryService/documents_test.go deleted file mode 100644 index 20b292a6..00000000 --- a/api/queryService/documents_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package queryservice_test - -import ( - "encoding/json" - "net/http" - "net/http/httptest" - "strings" - "testing" - - queryservice "queryorchestration/api/queryService" - "queryorchestration/internal/database" - "queryorchestration/internal/database/repository" - "queryorchestration/internal/document" - "queryorchestration/internal/serviceconfig" - "queryorchestration/internal/serviceconfig/queue/clientsync" - queuemock "queryorchestration/mocks/queue" - - "github.com/go-playground/validator/v10" - "github.com/google/uuid" - "github.com/labstack/echo/v4" - "github.com/pashagolub/pgxmock/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestListDocumentsByClientId(t *testing.T) { - pool, err := pgxmock.NewPool() - require.NoError(t, err) - cfg := &struct { - serviceconfig.BaseConfig - clientsync.ClientSyncConfig - }{} - cfg.DBPool = pool - cfg.DBQueries = repository.New(pool) - mockSQS := queuemock.NewMockSQSClient(t) - cfg.QueueClient = mockSQS - - clientId := "clientid" - - e := echo.New() - req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader("")) - req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) - rec := httptest.NewRecorder() - ctx := e.NewContext(req, rec) - - cons := queryservice.NewControllers(validator.New(), &queryservice.Services{ - Document: document.New(cfg), - }) - - ctx.Set("id", clientId) - doc := queryservice.ListDocuments{ - { - Id: uuid.New(), - Bucket: "bucketone", - Key: "keyone", - }, - } - - pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId). - WillReturnRows( - pgxmock.NewRows([]string{"id", "bucket", "key"}). - AddRow(database.MustToDBUUID(doc[0].Id), doc[0].Bucket, doc[0].Key), - ) - - err = cons.ListDocumentsByClientId(ctx, clientId) - assert.NoError(t, err) - assert.Equal(t, http.StatusOK, rec.Code) - - var res queryservice.ListDocuments - err = json.Unmarshal(rec.Body.Bytes(), &res) - assert.NoError(t, err) - assert.EqualExportedValues(t, doc, res) -} diff --git a/api/readme.md b/api/readme.md index 4cde9624..4c0aeb69 100644 --- a/api/readme.md +++ b/api/readme.md @@ -1,15 +1,18 @@ # Api related artifacts ## Prometheus metrics -Prometheus metrics are exposed for all api endpoints automatically at the standard `/metrics` endpoint. (http://localhost:8080/metrics) -## Swagger API documentation -Automatic API docs are generated and exposed for all routes at http://localhost:8080/swagger/index.html when the api server is running. +Prometheus metrics are exposed for all api endpoints automatically at the standard `/metrics` endpoint. (`http://localhost:8080/metrics`) + +## Swagger API documentation + +Automatic API docs are generated and exposed for all routes at `http://localhost:8080/swagger/index.html` when the api server is running. + +## Logging -## Logging Structured logging is built into all API routes automatically. -So for example here is a what a few API hits on queryService look like in the logs when using text (as opposed to json) +So for example here is a what a few API hits on queryAPI look like in the logs when using text (as opposed to json) ```bash ____ __ @@ -29,4 +32,4 @@ time=2025-02-05T13:38:39.807-08:00 level=INFO msg="HTTP request" method=GET uri= time=2025-02-05T13:38:39.871-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/doc.json status=200 latency=1.163167ms error= remote_ip=::1 time=2025-02-05T13:38:39.871-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/favicon-32x32.png status=200 latency=60.875µs error= remote_ip=::1 -``` \ No newline at end of file +``` diff --git a/cmd/queryService/main.go b/cmd/queryAPI/main.go similarity index 85% rename from cmd/queryService/main.go rename to cmd/queryAPI/main.go index 2c6f8ee6..590ee891 100644 --- a/cmd/queryService/main.go +++ b/cmd/queryAPI/main.go @@ -19,7 +19,7 @@ import ( "log/slog" "os" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/client" "queryorchestration/internal/collector" collectorset "queryorchestration/internal/collector/set" @@ -29,7 +29,7 @@ import ( "queryorchestration/internal/query/result" querytest "queryorchestration/internal/query/test" queryupdate "queryorchestration/internal/query/update" - service "queryorchestration/internal/server/service" + "queryorchestration/internal/server/api" "queryorchestration/internal/serviceconfig/queue/clientsync" "queryorchestration/internal/serviceconfig/queue/queryversionsync" @@ -37,8 +37,8 @@ import ( _ "github.com/lib/pq" ) -type QueryServiceConfig struct { - service.BaseConfig +type QueryAPIConfig struct { + api.BaseConfig clientsync.ClientSyncConfig queryversionsync.QueryVersionSyncConfig } @@ -46,7 +46,7 @@ type QueryServiceConfig struct { func main() { ctx := context.Background() - cfg := &QueryServiceConfig{} + cfg := &QueryAPIConfig{} cfg.RegisterHandlersFunc = func() (*openapi3.T, error) { exp := export.New() @@ -69,7 +69,7 @@ func main() { Query: que, }) - services := &queryservice.Services{ + services := &queryapi.Services{ Export: exp, Collector: col, CollectorSet: colupdate, @@ -80,11 +80,11 @@ func main() { Document: doc, } - cons := queryservice.NewControllers(cfg.GetValidator(), services) + cons := queryapi.NewControllers(cfg.GetValidator(), services) - queryservice.RegisterHandlers(cfg.Router, cons) + queryapi.RegisterHandlers(cfg.Router, cons) - swagger, err := queryservice.GetSwagger() + swagger, err := queryapi.GetSwagger() if err != nil { return nil, fmt.Errorf("error loading swagger: %s", err) } @@ -92,7 +92,7 @@ func main() { return swagger, nil } - server, err := service.New(ctx, cfg) + server, err := api.New(ctx, cfg) if err != nil { slog.Error(err.Error()) os.Exit(1) diff --git a/database/migrations/00000000000102_job_views.down.sql b/database/migrations/00000000000102_document_views.down.sql similarity index 100% rename from database/migrations/00000000000102_job_views.down.sql rename to database/migrations/00000000000102_document_views.down.sql diff --git a/database/migrations/00000000000102_document_views.up.sql b/database/migrations/00000000000102_document_views.up.sql new file mode 100644 index 00000000..5493ded1 --- /dev/null +++ b/database/migrations/00000000000102_document_views.up.sql @@ -0,0 +1,200 @@ +CREATE OR REPLACE FUNCTION listDocumentIDs( + _clientId uuid, + _batchSize INTEGER, + _offset INTEGER +) +RETURNS TABLE (id uuid, totalCount BIGINT) AS $$ +DECLARE + totalCount BIGINT := 0; +BEGIN + SELECT COUNT(*)::BIGINT INTO totalCount FROM documents WHERE clientId = _clientId; + + RETURN QUERY + SELECT d.id, totalCount + FROM documents as d + WHERE d.clientId = _clientId + ORDER BY d.id + LIMIT _batchSize + OFFSET _offset; +END; +$$ LANGUAGE plpgsql; + +CREATE VIEW currentCleanEntries as +WITH RankedExtractions AS ( + SELECT + dc.id, + dc.documentId, + dc.bucket, + dc.key, + dc.mimetype, + dc.fail, + dce.version, + ROW_NUMBER() OVER (PARTITION BY dc.documentId ORDER BY dc.id DESC, dce.id DESC) as row_num + FROM documents d + JOIN currentCollectorMinCleanVersions ccv ON d.clientId = ccv.clientId + JOIN documentCleans dc ON dc.documentId = d.id + JOIN documentCleanEntries dce ON dc.id = dce.cleanId + AND dce.version >= ccv.minCleanVersion +) +SELECT + id, + documentId, + bucket, + key, + version, + mimetype, + fail +FROM RankedExtractions +WHERE row_num = 1; + +CREATE VIEW currentTextEntries as +WITH RankedExtractions AS ( + SELECT + dte.id, + cc.documentId, + dte.bucket, + dte.key, + dte.version, + dte.cleanEntryId, + ROW_NUMBER() OVER (PARTITION BY cc.documentId ORDER BY dte.id DESC) as row_num + FROM documents d + JOIN currentCleanEntries cc on cc.documentId = d.id + JOIN currentCollectorMinTextVersions ctv ON ctv.clientId = d.clientId + JOIN documentTextExtractions dte ON dte.cleanEntryId = cc.id + AND dte.version >= ctv.minTextVersion +) +SELECT + id, + documentId, + bucket, + key, + version, + cleanEntryId +FROM RankedExtractions +WHERE row_num = 1; + +CREATE VIEW currentClientCanSync as +WITH RankedExtractions AS ( + SELECT + ccs.clientId, + ccs.canSync, + ROW_NUMBER() OVER (PARTITION BY ccs.clientId ORDER BY ccs.id DESC) as row_num + FROM clients c + JOIN clientCanSync ccs on c.id = ccs.clientId +) +SELECT + c.id as clientId, + coalesce(r.canSync, false) as canSync +FROM clients c +LEFT JOIN RankedExtractions r on r.clientId = c.id and r.row_num = 1; + +CREATE VIEW fullClients as +SELECT c.id, c.externalId, c.name, cs.canSync + FROM clients as c + JOIN currentClientCanSync as cs on cs.clientId = c.id; + +CREATE OR REPLACE FUNCTION listValidDocumentResults(doc_id uuid) +RETURNS TABLE (documentId uuid, queryId uuid, resultId uuid, value text) AS $$ +DECLARE + count_before INT; + count_after INT; + iterations INT := 0; +BEGIN + CREATE TEMPORARY TABLE allResults AS + WITH + docs AS ( + SELECT id as documentId, hash, clientId + FROM documents + WHERE id = doc_id + ), + query_dependency_tree AS ( + WITH RECURSIVE query_deps AS ( + SELECT + q.queryId, + unnest(q.requiredIds) AS requiredId + FROM collectorQueryDependencyTree AS q + JOIN docs AS d ON d.clientId = q.clientId + WHERE array_length(q.requiredIds, 1) > 0 + + UNION ALL + + SELECT + qd.queryId, + unnest(q.requiredIds) AS requiredId + FROM query_deps qd + JOIN collectorQueryDependencyTree q ON qd.requiredId = q.queryId + WHERE array_length(q.requiredIds, 1) > 0 + ) + SELECT + query_deps.queryId, + array_agg(DISTINCT requiredId) AS all_required_ids + FROM query_deps + GROUP BY query_deps.queryId + ), + docResults AS ( + SELECT + d.documentId, + q.queryId, + r.id AS resultId, + r.value, + q.requiredIds as directRequiredIds, + COALESCE(qdt.all_required_ids, ARRAY[]::uuid[]) AS allRequiredIds + FROM docs AS d + JOIN collectorQueryDependencyTree AS q ON q.clientId = d.clientId + LEFT JOIN query_dependency_tree qdt ON q.queryId = qdt.queryId + LEFT JOIN currentTextEntries AS tte ON tte.documentId = d.documentId + LEFT JOIN results AS r + ON q.queryId = r.queryId + AND r.queryVersion = q.queryVersion + AND tte.id = r.textEntryId + WHERE r.value is not null + ) + SELECT * FROM docResults dr; + + CREATE TEMPORARY TABLE finalResults AS + SELECT * from allResults where array_length(directRequiredIds, 1) is null; + + SELECT COUNT(*) INTO count_before FROM finalResults; + RAISE NOTICE 'Starting with % rows', count_before; + + LOOP + iterations := iterations + 1; + + INSERT INTO finalResults + SELECT dr.* + FROM allResults dr + WHERE + dr.directRequiredIds IS NOT NULL + AND NOT EXISTS ( + SELECT 1 + FROM unnest(dr.directRequiredIds) AS req_id(queryId) + WHERE NOT EXISTS ( + SELECT 1 + FROM allResults req_dr + WHERE req_dr.queryId = req_id.queryId + AND req_dr.resultId IN (SELECT fr.resultId FROM finalResults fr) + AND exists ( + select 1 from resultDependencies rrd + where dr.resultId = rrd.resultId + and req_dr.resultId = rrd.requiredResultId + ) + ) + ) + and dr.resultId NOT IN (SELECT fr.resultId FROM finalResults fr); + + GET DIAGNOSTICS count_after = ROW_COUNT; + RAISE NOTICE 'Iteration %: Additional Entries %', + iterations, count_after; + + IF count_after = 0 THEN + EXIT; + END IF; + END LOOP; + + RETURN QUERY SELECT tr.documentId, tr.queryId, tr.resultId, tr.value + FROM finalResults tr; + + DROP TABLE finalResults; + DROP TABLE allResults; +END; +$$ LANGUAGE plpgsql; diff --git a/database/migrations/00000000000102_job_views.up.sql b/database/migrations/00000000000102_job_views.up.sql deleted file mode 100644 index 70ada117..00000000 --- a/database/migrations/00000000000102_job_views.up.sql +++ /dev/null @@ -1,95 +0,0 @@ -CREATE OR REPLACE FUNCTION listDocumentIDs( - _clientId uuid, - _batchSize INTEGER, - _offset INTEGER -) -RETURNS TABLE (id uuid, totalCount BIGINT) AS $$ -DECLARE - totalCount BIGINT := 0; -BEGIN - SELECT COUNT(*)::BIGINT INTO totalCount FROM documents WHERE clientId = _clientId; - - RETURN QUERY - SELECT d.id, totalCount - FROM documents as d - WHERE d.clientId = _clientId - ORDER BY d.id - LIMIT _batchSize - OFFSET _offset; -END; -$$ LANGUAGE plpgsql; - -CREATE VIEW currentCleanEntries as -WITH RankedExtractions AS ( - SELECT - dc.id, - dc.documentId, - dc.bucket, - dc.key, - dc.mimetype, - dc.fail, - dce.version, - ROW_NUMBER() OVER (PARTITION BY dc.documentId ORDER BY dc.id DESC, dce.id DESC) as row_num - FROM documents d - JOIN currentCollectorMinCleanVersions ccv ON d.clientId = ccv.clientId - JOIN documentCleans dc ON dc.documentId = d.id - JOIN documentCleanEntries dce ON dc.id = dce.cleanId - AND dce.version >= ccv.minCleanVersion -) -SELECT - id, - documentId, - bucket, - key, - version, - mimetype, - fail -FROM RankedExtractions -WHERE row_num = 1; - -CREATE VIEW currentTextEntries as -WITH RankedExtractions AS ( - SELECT - dte.id, - cc.documentId, - dte.bucket, - dte.key, - dte.version, - dte.cleanEntryId, - ROW_NUMBER() OVER (PARTITION BY cc.documentId ORDER BY dte.id DESC) as row_num - FROM documents d - JOIN currentCleanEntries cc on cc.documentId = d.id - JOIN currentCollectorMinTextVersions ctv ON ctv.clientId = d.clientId - JOIN documentTextExtractions dte ON dte.cleanEntryId = cc.id - AND dte.version >= ctv.minTextVersion -) -SELECT - id, - documentId, - bucket, - key, - version, - cleanEntryId -FROM RankedExtractions -WHERE row_num = 1; - -CREATE VIEW currentClientCanSync as -WITH RankedExtractions AS ( - SELECT - ccs.clientId, - ccs.canSync, - ROW_NUMBER() OVER (PARTITION BY ccs.clientId ORDER BY ccs.id DESC) as row_num - FROM clients c - JOIN clientCanSync ccs on c.id = ccs.clientId -) -SELECT - c.id as clientId, - coalesce(r.canSync, false) as canSync -FROM clients c -LEFT JOIN RankedExtractions r on r.clientId = c.id and r.row_num = 1; - -CREATE VIEW fullClients as -SELECT c.id, c.externalId, c.name, cs.canSync - FROM clients as c - JOIN currentClientCanSync as cs on cs.clientId = c.id; - diff --git a/database/queries/client.sql b/database/queries/client.sql index 08efff02..768dfc4f 100644 --- a/database/queries/client.sql +++ b/database/queries/client.sql @@ -24,17 +24,19 @@ doc_clean_entries as ( SELECT d.id AS document_id, d.clientId as client_id, - cte.id AS clean_entry_id + cte.id AS clean_entry_id, + cte.fail as clean_fail FROM docs d LEFT JOIN currentCleanEntries cte ON cte.documentId = d.id - WHERE cte.id is null or cte.id is not null and cte.fail is null ), doc_text_entries AS ( -- Documents with their current text entries SELECT d.document_id, - cte.id AS text_entry_id + cte.id AS text_entry_id, + d.clean_entry_id, + d.clean_fail FROM doc_clean_entries d LEFT JOIN currentTextEntries cte ON cte.cleanEntryId = d.clean_entry_id @@ -51,6 +53,7 @@ required_results AS ( JOIN collectorQueryDependencyTree cqdt ON cqdt.clientId = d.client_id JOIN doc_text_entries dte ON dte.document_id = d.document_id and dte.text_entry_id IS NOT NULL + where d.clean_fail is null ), existing_results AS ( -- Valid results that exist @@ -87,15 +90,21 @@ SELECT ( OR -- Documents with no text entries - (NOT EXISTS (SELECT 1 FROM doc_text_entries WHERE text_entry_id IS NULL) + ( + NOT EXISTS ( + SELECT 1 FROM doc_text_entries + where clean_entry_id is null or + (clean_fail is null and text_entry_id is null) + ) - and + and - -- Documents with missing results - NOT EXISTS (SELECT 1 FROM missing_results) + -- Documents with missing results + NOT EXISTS (SELECT 1 FROM missing_results) - and + and - -- Documents with missing dependencies - NOT EXISTS (SELECT 1 FROM dependency_check)) + -- Documents with missing dependencies + NOT EXISTS (SELECT 1 FROM dependency_check) + )::bool )::bool as is_synced; diff --git a/database/queries/document.sql b/database/queries/document.sql index aa58f0a9..9b195348 100644 --- a/database/queries/document.sql +++ b/database/queries/document.sql @@ -1,25 +1,40 @@ --- name: GetDocument :one -SELECT id, clientId, hash FROM documents WHERE id = $1 LIMIT 1; +-- name: GetDocumentSummary :one +SELECT id, clientId, hash FROM documents WHERE id = $1; + +-- name: GetDocumentExternal :one +WITH +docs AS ( + SELECT id, hash, clientId + FROM documents + WHERE id = @documentId +), +namedResults AS ( + SELECT + q.name, + dd.id, + d.value + FROM currentCollectorQueries AS q + JOIN docs as dd on dd.clientId = q.clientId + LEFT JOIN listValidDocumentResults(@documentId) AS d + ON d.queryId = q.queryId and q.name is not null +) +SELECT + d.id, + c.externalId AS clientId, + d.hash, + COALESCE(jsonb_object_agg(r.name, r.value) FILTER (WHERE r.name IS NOT NULL), '{}') AS fields +FROM docs AS d +JOIN clients AS c ON c.id = d.clientId +LEFT JOIN namedResults AS r ON d.id = r.id +GROUP BY d.id, c.externalId, d.hash; -- name: ListDocumentsByClientExternalId :many WITH client as ( SELECT id from clients where externalId = @clientId -), -docs as ( - SELECT d.id - from documents as d - JOIN client as c on d.clientId = c.id -), -entries as ( - SELECT - de.documentId, - de.bucket, - de.key, - ROW_NUMBER() OVER (PARTITION BY de.documentId ORDER BY de.id DESC) as rowNumber - FROM docs d - JOIN documentEntries de on d.id = de.documentId ) -SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1; +SELECT d.id, d.hash + from documents as d + JOIN client as c on d.clientId = c.id; -- name: CreateDocument :one INSERT INTO documents (clientId, hash) VALUES ($1, $2) RETURNING id; diff --git a/database/queries/text.sql b/database/queries/text.sql index f45aff88..cfa7a355 100644 --- a/database/queries/text.sql +++ b/database/queries/text.sql @@ -3,8 +3,8 @@ SELECT EXISTS( SELECT 1 FROM currentTextEntries WHERE documentId = @documentId ); --- name: AddDocumentTextEntry :exec -INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4); +-- name: AddDocumentTextEntry :one +INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4) returning id; -- name: GetTextEntryByDocId :one SELECT id, documentId, bucket, key, version, cleanEntryId diff --git a/deployments/compose.local.yaml b/deployments/compose.local.yaml index 23a978c7..78536803 100644 --- a/deployments/compose.local.yaml +++ b/deployments/compose.local.yaml @@ -185,9 +185,9 @@ services: networks: - server-network - query_service: + query_api: image: queryorchestration:latest - command: ["./queryService"] + command: ["./queryAPI"] depends_on: localstack: condition: service_healthy diff --git a/deployments/prometheus.allmetrics.yaml b/deployments/prometheus.allmetrics.yaml index 74fd2bae..d9267dc2 100644 --- a/deployments/prometheus.allmetrics.yaml +++ b/deployments/prometheus.allmetrics.yaml @@ -4,10 +4,10 @@ global: scrape_interval: 10s scrape_configs: - - job_name: "query_service" + - job_name: "query_api" static_configs: - targets: - - "query_service:8080" + - "query_api:8080" metrics_path: "/metrics" - job_name: "doc_init_runner" diff --git a/deployments/readme.md b/deployments/readme.md index ee1e6764..98d86f22 100644 --- a/deployments/readme.md +++ b/deployments/readme.md @@ -1,25 +1,26 @@ # Deployments ## Note about host service testing -If you want the docker prometheus in this stack to pull from your -locally running service on localhost:8080 then edit the -`compose.local.yaml` and change the reference from + +If you want the docker prometheus in this stack to pull from your +locally running service on localhost:8080 then edit the +`compose.local.yaml` and change the reference from `./prometheus.allmetrics.yaml:/etc/prometheus/prometheus.yml` to `./prometheus.localservice.yaml:/etc/prometheus/prometheus.yml` - ## Local -When running `task compose:up:local` prometheus will be available on -http://localhost:9090 + +When running `task compose:up:local` prometheus will be available on +`http://localhost:9090` When running `task compose:up` prometheus will be available on -http://localhost:9091 +`http://localhost:9091` To see which target services are being scraped by prometheus you can go to http:// localhost: [port] /targets - ### Local with service on host -If you need to run a service directly on the host for debugging then use + +If you need to run a service directly on the host for debugging then use `task compose:up:test` and then run the service like -`PGPORT=5430 go run ./cmd/queryService` \ No newline at end of file +`PGPORT=5430 go run ./cmd/queryAPI` diff --git a/devbox.json b/devbox.json index b9141d42..9343d894 100644 --- a/devbox.json +++ b/devbox.json @@ -35,13 +35,9 @@ "env_from": ".env", "packages": [ "golangci-lint@1.64.5", - "protolint@0.50.5", "yamllint@1.35.1", "sqlc@1.27.0", - "protoc-gen-go@1.35.1", - "protoc-gen-go-grpc@1.3.0", "go-migrate@4.18.1", - "protobuf@28.3", "go-task@3.39.2", "hadolint@2.12.0", "gotools@0.25.0", @@ -52,7 +48,9 @@ "postgresql@17.2", "bc@1.07.1", "gomarkdoc@1.1.0", - "go@1.24.0" + "go@1.24.0", + "sqlcheck@1.3", + "docker-client@27.3.1" ], "shell": { "init_hook": [ diff --git a/devbox.lock b/devbox.lock index 1a9c2f73..9e86e099 100644 --- a/devbox.lock +++ b/devbox.lock @@ -113,6 +113,54 @@ } } }, + "docker-client@27.3.1": { + "last_modified": "2024-12-03T12:40:06Z", + "resolved": "github:NixOS/nixpkgs/566e53c2ad750c84f6d31f9ccb9d00f823165550#docker-client", + "source": "devbox-search", + "version": "27.3.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/03vbya3x94lygm1242d7kqx63ia2qm4v-docker-27.3.1", + "default": true + } + ], + "store_path": "/nix/store/03vbya3x94lygm1242d7kqx63ia2qm4v-docker-27.3.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/7y6rl5mw8d4w95c05hdaxb36rzb4gxqr-docker-27.3.1", + "default": true + } + ], + "store_path": "/nix/store/7y6rl5mw8d4w95c05hdaxb36rzb4gxqr-docker-27.3.1" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/fn3prnmm4nnpw03z4lqilhqj9grdxvm7-docker-27.3.1", + "default": true + } + ], + "store_path": "/nix/store/fn3prnmm4nnpw03z4lqilhqj9grdxvm7-docker-27.3.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/n47072r68jh4x2avxwgxirj8652h2xdb-docker-27.3.1", + "default": true + } + ], + "store_path": "/nix/store/n47072r68jh4x2avxwgxirj8652h2xdb-docker-27.3.1" + } + } + }, "go-migrate@4.18.1": { "last_modified": "2024-12-23T21:10:33Z", "resolved": "github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d#go-migrate", @@ -674,198 +722,6 @@ } } }, - "protobuf@28.3": { - "last_modified": "2024-12-03T12:40:06Z", - "resolved": "github:NixOS/nixpkgs/566e53c2ad750c84f6d31f9ccb9d00f823165550#protobuf", - "source": "devbox-search", - "version": "28.3", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/q04cfyxpr3ijb038bjwg6h10djlzrvzq-protobuf-28.3", - "default": true - } - ], - "store_path": "/nix/store/q04cfyxpr3ijb038bjwg6h10djlzrvzq-protobuf-28.3" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/ar3x733vglzmgwlwqm712chc4lsvmg6l-protobuf-28.3", - "default": true - } - ], - "store_path": "/nix/store/ar3x733vglzmgwlwqm712chc4lsvmg6l-protobuf-28.3" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/4xfgsh5dis62pr1776qnk6x6j5jn8zn0-protobuf-28.3", - "default": true - } - ], - "store_path": "/nix/store/4xfgsh5dis62pr1776qnk6x6j5jn8zn0-protobuf-28.3" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/q9masc42g6rwzkpi8ma4qwbnmkzj7vz2-protobuf-28.3", - "default": true - } - ], - "store_path": "/nix/store/q9masc42g6rwzkpi8ma4qwbnmkzj7vz2-protobuf-28.3" - } - } - }, - "protoc-gen-go-grpc@1.3.0": { - "last_modified": "2024-12-03T12:40:06Z", - "resolved": "github:NixOS/nixpkgs/566e53c2ad750c84f6d31f9ccb9d00f823165550#protoc-gen-go-grpc", - "source": "devbox-search", - "version": "1.3.0", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/lak8kwpnagiwham2byzg3qilr78bvqfv-protoc-gen-go-grpc-1.3.0", - "default": true - } - ], - "store_path": "/nix/store/lak8kwpnagiwham2byzg3qilr78bvqfv-protoc-gen-go-grpc-1.3.0" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/8chmakb7pix8kj4jv9gyyvdav2l22idk-protoc-gen-go-grpc-1.3.0", - "default": true - } - ], - "store_path": "/nix/store/8chmakb7pix8kj4jv9gyyvdav2l22idk-protoc-gen-go-grpc-1.3.0" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/7v7jj7d21im7saqy41vbrlwqjzzagnqp-protoc-gen-go-grpc-1.3.0", - "default": true - } - ], - "store_path": "/nix/store/7v7jj7d21im7saqy41vbrlwqjzzagnqp-protoc-gen-go-grpc-1.3.0" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/d79cxdsbdqs1l4aph985lflcix67bkb8-protoc-gen-go-grpc-1.3.0", - "default": true - } - ], - "store_path": "/nix/store/d79cxdsbdqs1l4aph985lflcix67bkb8-protoc-gen-go-grpc-1.3.0" - } - } - }, - "protoc-gen-go@1.35.1": { - "last_modified": "2024-11-16T04:25:12Z", - "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#protoc-gen-go", - "source": "devbox-search", - "version": "1.35.1", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/5i406gv649fg1g7s8rcajbknm0kvsm85-protoc-gen-go-1.35.1", - "default": true - } - ], - "store_path": "/nix/store/5i406gv649fg1g7s8rcajbknm0kvsm85-protoc-gen-go-1.35.1" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/i42sm8xdgh3v1434q0haxqv0akxw2k60-protoc-gen-go-1.35.1", - "default": true - } - ], - "store_path": "/nix/store/i42sm8xdgh3v1434q0haxqv0akxw2k60-protoc-gen-go-1.35.1" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/34b5ry7cvnvckvgaf2xd4a46p78z1w2i-protoc-gen-go-1.35.1", - "default": true - } - ], - "store_path": "/nix/store/34b5ry7cvnvckvgaf2xd4a46p78z1w2i-protoc-gen-go-1.35.1" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/0l0x36ajfyr7gav993hw2i4g39zl9x08-protoc-gen-go-1.35.1", - "default": true - } - ], - "store_path": "/nix/store/0l0x36ajfyr7gav993hw2i4g39zl9x08-protoc-gen-go-1.35.1" - } - } - }, - "protolint@0.50.5": { - "last_modified": "2024-11-28T07:51:56Z", - "resolved": "github:NixOS/nixpkgs/226216574ada4c3ecefcbbec41f39ce4655f78ef#protolint", - "source": "devbox-search", - "version": "0.50.5", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/039zwhkiv8klph9nk2yicyrddh3d0xxh-protolint-0.50.5", - "default": true - } - ], - "store_path": "/nix/store/039zwhkiv8klph9nk2yicyrddh3d0xxh-protolint-0.50.5" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/rhmmdymbshdw6f8s9v00x1xh4kl4dv94-protolint-0.50.5", - "default": true - } - ], - "store_path": "/nix/store/rhmmdymbshdw6f8s9v00x1xh4kl4dv94-protolint-0.50.5" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/kinv97rh0zsa45mnhnll9qnd4i0r13a0-protolint-0.50.5", - "default": true - } - ], - "store_path": "/nix/store/kinv97rh0zsa45mnhnll9qnd4i0r13a0-protolint-0.50.5" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/1qz26rz830l9zf2dlg27mvgk9g53jdxm-protolint-0.50.5", - "default": true - } - ], - "store_path": "/nix/store/1qz26rz830l9zf2dlg27mvgk9g53jdxm-protolint-0.50.5" - } - } - }, "sqlc@1.27.0": { "last_modified": "2024-12-23T21:10:33Z", "resolved": "github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d#sqlc", @@ -914,6 +770,54 @@ } } }, + "sqlcheck@1.3": { + "last_modified": "2025-02-07T11:26:36Z", + "resolved": "github:NixOS/nixpkgs/d98abf5cf5914e5e4e9d57205e3af55ca90ffc1d#sqlcheck", + "source": "devbox-search", + "version": "1.3", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/srp4f0d3hlf35sn9bjx48hxsg8a335qk-sqlcheck-1.3", + "default": true + } + ], + "store_path": "/nix/store/srp4f0d3hlf35sn9bjx48hxsg8a335qk-sqlcheck-1.3" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/548sicnzac0ckzgjhs3kh7fybmxpk81s-sqlcheck-1.3", + "default": true + } + ], + "store_path": "/nix/store/548sicnzac0ckzgjhs3kh7fybmxpk81s-sqlcheck-1.3" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/77f59r1383ypf5byjfmfz93sskkfm0c9-sqlcheck-1.3", + "default": true + } + ], + "store_path": "/nix/store/77f59r1383ypf5byjfmfz93sskkfm0c9-sqlcheck-1.3" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/wi6hk3ff34y85bgjb5di7giz7i9lwdw6-sqlcheck-1.3", + "default": true + } + ], + "store_path": "/nix/store/wi6hk3ff34y85bgjb5di7giz7i9lwdw6-sqlcheck-1.3" + } + } + }, "vacuum-go@0.14.1": { "last_modified": "2024-11-28T07:51:56Z", "resolved": "github:NixOS/nixpkgs/226216574ada4c3ecefcbbec41f39ce4655f78ef#vacuum-go", diff --git a/docs/README.md b/docs/README.md index 6fc81f17..4072f0a8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -74,17 +74,7 @@ It demonstrates: 5. Proper error handling -## queryRunner - -**Listens For**: Body Containing Document ID and Query ID - -**Action**. - -Run the query for the given document and store the result. - -Events with the document id and downstream query ids are pushed to the QUERY queue. - -## queryService +## queryAPI This API currently manages all user entities to be managed. This allows users of the service to change required entities and processes. @@ -100,6 +90,16 @@ The entities in question: - Export - An export is a manually started process which outputs the results for a client to a given location. +## queryRunner + +**Listens For**: Body Containing Document ID and Query ID + +**Action**. + +Run the query for the given document and store the result. + +Events with the document id and downstream query ids are pushed to the QUERY queue. + ## querySyncRunner **Listens For**: Body Containing Document ID diff --git a/internal/client/sync/sync_test.go b/internal/client/sync/sync_test.go index c1c3a7fa..d59293f5 100644 --- a/internal/client/sync/sync_test.go +++ b/internal/client/sync/sync_test.go @@ -42,7 +42,7 @@ func TestTrigger(t *testing.T) { svc := New(cfg) clientId := uuid.New() - docs := []document.Document{ + docs := []document.DocumentSummary{ { ID: uuid.New(), ClientID: clientId, diff --git a/internal/database/repository/client.sql.go b/internal/database/repository/client.sql.go index 51bb3afa..842969e8 100644 --- a/internal/database/repository/client.sql.go +++ b/internal/database/repository/client.sql.go @@ -96,17 +96,19 @@ doc_clean_entries as ( SELECT d.id AS document_id, d.clientId as client_id, - cte.id AS clean_entry_id + cte.id AS clean_entry_id, + cte.fail as clean_fail FROM docs d LEFT JOIN currentCleanEntries cte ON cte.documentId = d.id - WHERE cte.id is null or cte.id is not null and cte.fail is null ), doc_text_entries AS ( -- Documents with their current text entries SELECT d.document_id, - cte.id AS text_entry_id + cte.id AS text_entry_id, + d.clean_entry_id, + d.clean_fail FROM doc_clean_entries d LEFT JOIN currentTextEntries cte ON cte.cleanEntryId = d.clean_entry_id @@ -123,6 +125,7 @@ required_results AS ( JOIN collectorQueryDependencyTree cqdt ON cqdt.clientId = d.client_id JOIN doc_text_entries dte ON dte.document_id = d.document_id and dte.text_entry_id IS NOT NULL + where d.clean_fail is null ), existing_results AS ( -- Valid results that exist @@ -159,17 +162,23 @@ SELECT ( OR -- Documents with no text entries - (NOT EXISTS (SELECT 1 FROM doc_text_entries WHERE text_entry_id IS NULL) + ( + NOT EXISTS ( + SELECT 1 FROM doc_text_entries + where clean_entry_id is null or + (clean_fail is null and text_entry_id is null) + ) - and + and - -- Documents with missing results - NOT EXISTS (SELECT 1 FROM missing_results) + -- Documents with missing results + NOT EXISTS (SELECT 1 FROM missing_results) - and + and - -- Documents with missing dependencies - NOT EXISTS (SELECT 1 FROM dependency_check)) + -- Documents with missing dependencies + NOT EXISTS (SELECT 1 FROM dependency_check) + )::bool )::bool as is_synced ` @@ -185,17 +194,19 @@ SELECT ( // SELECT // d.id AS document_id, // d.clientId as client_id, -// cte.id AS clean_entry_id +// cte.id AS clean_entry_id, +// cte.fail as clean_fail // FROM // docs d // LEFT JOIN currentCleanEntries cte ON cte.documentId = d.id -// WHERE cte.id is null or cte.id is not null and cte.fail is null // ), // doc_text_entries AS ( // -- Documents with their current text entries // SELECT // d.document_id, -// cte.id AS text_entry_id +// cte.id AS text_entry_id, +// d.clean_entry_id, +// d.clean_fail // FROM // doc_clean_entries d // LEFT JOIN currentTextEntries cte ON cte.cleanEntryId = d.clean_entry_id @@ -212,6 +223,7 @@ SELECT ( // JOIN collectorQueryDependencyTree cqdt ON cqdt.clientId = d.client_id // JOIN doc_text_entries dte ON dte.document_id = d.document_id // and dte.text_entry_id IS NOT NULL +// where d.clean_fail is null // ), // existing_results AS ( // -- Valid results that exist @@ -248,17 +260,23 @@ SELECT ( // OR // // -- Documents with no text entries -// (NOT EXISTS (SELECT 1 FROM doc_text_entries WHERE text_entry_id IS NULL) +// ( +// NOT EXISTS ( +// SELECT 1 FROM doc_text_entries +// where clean_entry_id is null or +// (clean_fail is null and text_entry_id is null) +// ) // -// and +// and // -// -- Documents with missing results -// NOT EXISTS (SELECT 1 FROM missing_results) +// -- Documents with missing results +// NOT EXISTS (SELECT 1 FROM missing_results) // -// and +// and // -// -- Documents with missing dependencies -// NOT EXISTS (SELECT 1 FROM dependency_check)) +// -- Documents with missing dependencies +// NOT EXISTS (SELECT 1 FROM dependency_check) +// )::bool // )::bool as is_synced func (q *Queries) IsClientSynced(ctx context.Context, dollar_1 pgtype.UUID) (bool, error) { row := q.db.QueryRow(ctx, isClientSynced, dollar_1) diff --git a/internal/database/repository/document.sql.go b/internal/database/repository/document.sql.go index 3117c232..0e77edbe 100644 --- a/internal/database/repository/document.sql.go +++ b/internal/database/repository/document.sql.go @@ -48,20 +48,6 @@ func (q *Queries) CreateDocument(ctx context.Context, arg *CreateDocumentParams) return id, err } -const getDocument = `-- name: GetDocument :one -SELECT id, clientId, hash FROM documents WHERE id = $1 LIMIT 1 -` - -// GetDocument -// -// SELECT id, clientId, hash FROM documents WHERE id = $1 LIMIT 1 -func (q *Queries) GetDocument(ctx context.Context, id pgtype.UUID) (*Document, error) { - row := q.db.QueryRow(ctx, getDocument, id) - var i Document - err := row.Scan(&i.ID, &i.Clientid, &i.Hash) - return &i, err -} - const getDocumentEntry = `-- name: GetDocumentEntry :one SELECT documentId, bucket, key FROM documentEntries WHERE documentId = $1 ORDER BY id DESC LIMIT 1 ` @@ -82,6 +68,80 @@ func (q *Queries) GetDocumentEntry(ctx context.Context, documentid pgtype.UUID) return &i, err } +const getDocumentExternal = `-- name: GetDocumentExternal :one +WITH +docs AS ( + SELECT id, hash, clientId + FROM documents + WHERE id = $1 +), +namedResults AS ( + SELECT + q.name, + dd.id, + d.value + FROM currentCollectorQueries AS q + JOIN docs as dd on dd.clientId = q.clientId + LEFT JOIN listValidDocumentResults($1) AS d + ON d.queryId = q.queryId and q.name is not null +) +SELECT + d.id, + c.externalId AS clientId, + d.hash, + COALESCE(jsonb_object_agg(r.name, r.value) FILTER (WHERE r.name IS NOT NULL), '{}') AS fields +FROM docs AS d +JOIN clients AS c ON c.id = d.clientId +LEFT JOIN namedResults AS r ON d.id = r.id +GROUP BY d.id, c.externalId, d.hash +` + +type GetDocumentExternalRow struct { + ID pgtype.UUID `db:"id"` + Clientid string `db:"clientid"` + Hash string `db:"hash"` + Fields []byte `db:"fields"` +} + +// GetDocumentExternal +// +// WITH +// docs AS ( +// SELECT id, hash, clientId +// FROM documents +// WHERE id = $1 +// ), +// namedResults AS ( +// SELECT +// q.name, +// dd.id, +// d.value +// FROM currentCollectorQueries AS q +// JOIN docs as dd on dd.clientId = q.clientId +// LEFT JOIN listValidDocumentResults($1) AS d +// ON d.queryId = q.queryId and q.name is not null +// ) +// SELECT +// d.id, +// c.externalId AS clientId, +// d.hash, +// COALESCE(jsonb_object_agg(r.name, r.value) FILTER (WHERE r.name IS NOT NULL), '{}') AS fields +// FROM docs AS d +// JOIN clients AS c ON c.id = d.clientId +// LEFT JOIN namedResults AS r ON d.id = r.id +// GROUP BY d.id, c.externalId, d.hash +func (q *Queries) GetDocumentExternal(ctx context.Context, documentid pgtype.UUID) (*GetDocumentExternalRow, error) { + row := q.db.QueryRow(ctx, getDocumentExternal, documentid) + var i GetDocumentExternalRow + err := row.Scan( + &i.ID, + &i.Clientid, + &i.Hash, + &i.Fields, + ) + return &i, err +} + const getDocumentIDByHash = `-- name: GetDocumentIDByHash :one SELECT id FROM documents WHERE hash = $1 and clientId = $2 ` @@ -101,6 +161,20 @@ func (q *Queries) GetDocumentIDByHash(ctx context.Context, arg *GetDocumentIDByH return id, err } +const getDocumentSummary = `-- name: GetDocumentSummary :one +SELECT id, clientId, hash FROM documents WHERE id = $1 +` + +// GetDocumentSummary +// +// SELECT id, clientId, hash FROM documents WHERE id = $1 +func (q *Queries) GetDocumentSummary(ctx context.Context, id pgtype.UUID) (*Document, error) { + row := q.db.QueryRow(ctx, getDocumentSummary, id) + var i Document + err := row.Scan(&i.ID, &i.Clientid, &i.Hash) + return &i, err +} + const listDocumentIDsBatch = `-- name: ListDocumentIDsBatch :many SELECT id, totalCount FROM listDocumentIDs($1, $2, $3) ` @@ -142,50 +216,25 @@ func (q *Queries) ListDocumentIDsBatch(ctx context.Context, arg *ListDocumentIDs const listDocumentsByClientExternalId = `-- name: ListDocumentsByClientExternalId :many WITH client as ( SELECT id from clients where externalId = $1 -), -docs as ( - SELECT d.id - from documents as d - JOIN client as c on d.clientId = c.id -), -entries as ( - SELECT - de.documentId, - de.bucket, - de.key, - ROW_NUMBER() OVER (PARTITION BY de.documentId ORDER BY de.id DESC) as rowNumber - FROM docs d - JOIN documentEntries de on d.id = de.documentId ) -SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1 +SELECT d.id, d.hash + from documents as d + JOIN client as c on d.clientId = c.id ` type ListDocumentsByClientExternalIdRow struct { - ID pgtype.UUID `db:"id"` - Bucket string `db:"bucket"` - Key string `db:"key"` + ID pgtype.UUID `db:"id"` + Hash string `db:"hash"` } // ListDocumentsByClientExternalId // // WITH client as ( // SELECT id from clients where externalId = $1 -// ), -// docs as ( -// SELECT d.id -// from documents as d -// JOIN client as c on d.clientId = c.id -// ), -// entries as ( -// SELECT -// de.documentId, -// de.bucket, -// de.key, -// ROW_NUMBER() OVER (PARTITION BY de.documentId ORDER BY de.id DESC) as rowNumber -// FROM docs d -// JOIN documentEntries de on d.id = de.documentId // ) -// SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1 +// SELECT d.id, d.hash +// from documents as d +// JOIN client as c on d.clientId = c.id func (q *Queries) ListDocumentsByClientExternalId(ctx context.Context, clientid string) ([]*ListDocumentsByClientExternalIdRow, error) { rows, err := q.db.Query(ctx, listDocumentsByClientExternalId, clientid) if err != nil { @@ -195,7 +244,7 @@ func (q *Queries) ListDocumentsByClientExternalId(ctx context.Context, clientid items := []*ListDocumentsByClientExternalIdRow{} for rows.Next() { var i ListDocumentsByClientExternalIdRow - if err := rows.Scan(&i.ID, &i.Bucket, &i.Key); err != nil { + if err := rows.Scan(&i.ID, &i.Hash); err != nil { return nil, err } items = append(items, &i) diff --git a/internal/database/repository/document_test.go b/internal/database/repository/document_test.go index dd321b6e..348ad2ca 100644 --- a/internal/database/repository/document_test.go +++ b/internal/database/repository/document_test.go @@ -2,8 +2,6 @@ package repository_test import ( "context" - "os" - "path" "testing" "queryorchestration/internal/database/repository" @@ -20,8 +18,7 @@ func TestDocument(t *testing.T) { ctx := context.Background() cfg := &serviceconfig.BaseConfig{} - test.SetCfgProvider(t, cfg) - cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../..")) + test.SetCfgProviderWithBasePath(t, cfg, "../../..") _, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{ Cfg: cfg, RunMigrations: true, @@ -61,8 +58,7 @@ func TestDocument(t *testing.T) { docs, err = queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 1) - assert.Equal(t, bucketone, docs[0].Bucket) - assert.Equal(t, keyone, docs[0].Key) + assert.Equal(t, hash, docs[0].Hash) documentTwoID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ Clientid: clientId, @@ -100,7 +96,7 @@ func TestDocument(t *testing.T) { documentThreeId, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ Clientid: clientTwoId, - Hash: "example_hash", + Hash: hash, }) assert.NoError(t, err) @@ -119,10 +115,9 @@ func TestDocument(t *testing.T) { docs, err = queries.ListDocumentsByClientExternalId(ctx, externalTwoId) assert.NoError(t, err) assert.Len(t, docs, 1) - assert.Equal(t, bucketthree, docs[0].Bucket) - assert.Equal(t, keythree, docs[0].Key) + assert.Equal(t, hash, docs[0].Hash) - doc, err := queries.GetDocument(ctx, id) + doc, err := queries.GetDocumentSummary(ctx, id) assert.NoError(t, err) assert.EqualExportedValues(t, &repository.Document{ ID: id, @@ -130,6 +125,15 @@ func TestDocument(t *testing.T) { Hash: hash, }, doc) + docext, err := queries.GetDocumentExternal(ctx, id) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: id, + Clientid: externalId, + Hash: hash, + Fields: []byte("{}"), + }, docext) + docid, err := queries.GetDocumentIDByHash(ctx, &repository.GetDocumentIDByHashParams{ Hash: hash, Clientid: clientId, diff --git a/internal/database/repository/job_test.go b/internal/database/repository/job_test.go deleted file mode 100644 index 1366ecf3..00000000 --- a/internal/database/repository/job_test.go +++ /dev/null @@ -1,587 +0,0 @@ -package repository_test - -import ( - "context" - "os" - "path" - "testing" - - "queryorchestration/internal/database/repository" - "queryorchestration/internal/serviceconfig" - "queryorchestration/internal/test" - - "github.com/stretchr/testify/assert" -) - -func TestListClientDocumentIDs(t *testing.T) { - if testing.Short() { - t.Skip("Skipping long test in short mode") - } - ctx := context.Background() - - cfg := &serviceconfig.BaseConfig{} - test.SetCfgProvider(t, cfg) - cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../..")) - _, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{ - Cfg: cfg, - RunMigrations: true, - }) - defer cleanup() - - queries := cfg.GetDBQueries() - - id, err := queries.CreateClient(ctx, &repository.CreateClientParams{ - Name: "example_client", - Externalid: "EXAMPLE", - }) - assert.NoError(t, err) - - ids, err := queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ - Clientid: id, - Batchsize: 1, - Pageoffset: 0, - }) - assert.NoError(t, err) - assert.Len(t, ids, 0) - - docOne, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ - Clientid: id, - Hash: "example_hash", - }) - assert.NoError(t, err) - - ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ - Clientid: id, - Batchsize: 1, - Pageoffset: 0, - }) - assert.NoError(t, err) - assert.Len(t, ids, 1) - total := int64(1) - assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ - { - ID: docOne, - Totalcount: &total, - }, - }, ids) - - docTwo, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ - Clientid: id, - Hash: "example_hash_two", - }) - assert.NoError(t, err) - - ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ - Clientid: id, - Batchsize: 1, - Pageoffset: 0, - }) - assert.NoError(t, err) - assert.Len(t, ids, 1) - total = int64(2) - assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ - { - ID: docOne, - Totalcount: &total, - }, - }, ids) - - ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ - Clientid: id, - Batchsize: 1, - Pageoffset: 1, - }) - assert.NoError(t, err) - assert.Len(t, ids, 1) - assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ - { - ID: docTwo, - Totalcount: &total, - }, - }, ids) - - ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ - Clientid: id, - Batchsize: 2, - Pageoffset: 0, - }) - assert.NoError(t, err) - assert.Len(t, ids, 2) - assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ - { - ID: docOne, - Totalcount: &total, - }, - { - ID: docTwo, - Totalcount: &total, - }, - }, ids) -} - -func TestClientSync(t *testing.T) { - if testing.Short() { - t.Skip("Skipping long test in short mode") - } - ctx := context.Background() - - cfg := &serviceconfig.BaseConfig{} - test.SetCfgProvider(t, cfg) - cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../..")) - _, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{ - Cfg: cfg, - RunMigrations: true, - }) - defer cleanup() - - queries := cfg.GetDBQueries() - - contextQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeContextFull)) - assert.NoError(t, err) - _, err = queries.AddLatestQueryVersion(ctx, contextQueryID) - assert.NoError(t, err) - err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ - Queryid: contextQueryID, - Versionid: 1, - }) - assert.NoError(t, err) - jsonQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor)) - assert.NoError(t, err) - _, err = queries.AddLatestQueryVersion(ctx, jsonQueryID) - assert.NoError(t, err) - err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ - Queryid: jsonQueryID, - Versionid: 1, - }) - assert.NoError(t, err) - err = queries.AddRequiredQuery(ctx, &repository.AddRequiredQueryParams{ - Queryid: jsonQueryID, - Requiredqueryid: contextQueryID, - Addedversion: 1, - }) - assert.NoError(t, err) - - clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ - Name: "example_client", - Externalid: "EXAMPLE", - }) - assert.NoError(t, err) - - _, err = queries.AddLatestCollectorVersion(ctx, clientId) - assert.NoError(t, err) - err = queries.SetActiveCollectorVersion(ctx, &repository.SetActiveCollectorVersionParams{ - Versionid: 1, - Clientid: clientId, - }) - assert.NoError(t, err) - err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ - Clientid: clientId, - Queryid: jsonQueryID, - Addedversion: 1, - Name: "example_key", - }) - assert.NoError(t, err) - - isSynced, err := queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - documentNoCleanID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ - Clientid: clientId, - Hash: "example_noclean", - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - bucket := "example_bucket" - key := "example_key" - cleanid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ - Documentid: documentNoCleanID, - Fail: repository.NullCleanfailtype{ - Valid: true, - Cleanfailtype: repository.CleanfailtypeInvalidMimetype, - }, - }) - assert.NoError(t, err) - err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ - Cleanid: cleanid, - Version: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - documentID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ - Clientid: clientId, - Hash: "example_hash", - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - keytwo := "example_key_2" - cleantwoid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ - Documentid: documentID, - Bucket: &bucket, - Key: &keytwo, - Mimetype: repository.NullCleanmimetype{ - Valid: true, - Cleanmimetype: repository.CleanmimetypeApplicationPdf, - }, - }) - assert.NoError(t, err) - err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ - Cleanid: cleantwoid, - Version: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ - Version: 1, - Bucket: "hi", - Key: "hello", - Cleanentryid: cleantwoid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - textentry, err := queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) - - depresultid, err := queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: contextQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - resultid, err := queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: jsonQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: resultid, - Requiredresultid: depresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - _, err = queries.AddLatestQueryVersion(ctx, contextQueryID) - assert.NoError(t, err) - err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ - Queryid: contextQueryID, - Versionid: 2, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - depresultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: contextQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 2, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - resultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: jsonQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: resultid, - Requiredresultid: depresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ - Version: 1, - Bucket: "hi", - Key: "hello", - Cleanentryid: cleantwoid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - textentry, err = queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) - - depresultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: contextQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 2, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - resultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: jsonQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: resultid, - Requiredresultid: depresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - cleanthreeid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ - Documentid: documentID, - Bucket: &bucket, - Key: &key, - Mimetype: repository.NullCleanmimetype{ - Valid: true, - Cleanmimetype: repository.CleanmimetypeApplicationPdf, - }, - }) - assert.NoError(t, err) - err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ - Cleanid: cleanthreeid, - Version: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ - Version: 1, - Bucket: "hi", - Key: "hello", - Cleanentryid: cleanthreeid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - textentry, err = queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) - - depresultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: contextQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 2, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - resultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: jsonQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: resultid, - Requiredresultid: depresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - _, err = queries.AddLatestCollectorVersion(ctx, clientId) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - collversion := int32(2) - err = queries.SetActiveCollectorVersion(ctx, &repository.SetActiveCollectorVersionParams{ - Versionid: 2, - Clientid: clientId, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - err = queries.RemoveCollectorQuery(ctx, &repository.RemoveCollectorQueryParams{ - Clientid: clientId, - Queryid: jsonQueryID, - Removedversion: &collversion, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ - Clientid: clientId, - Queryid: jsonQueryID, - Addedversion: 2, - Name: "second_key", - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ - Clientid: clientId, - Queryid: contextQueryID, - Addedversion: 2, - Name: "example_key", - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) - - superQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor)) - assert.NoError(t, err) - _, err = queries.AddLatestQueryVersion(ctx, superQueryID) - assert.NoError(t, err) - err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ - Queryid: superQueryID, - Versionid: 1, - }) - assert.NoError(t, err) - err = queries.AddRequiredQuery(ctx, &repository.AddRequiredQueryParams{ - Queryid: contextQueryID, - Requiredqueryid: superQueryID, - Addedversion: 1, - }) - assert.NoError(t, err) - - superresultid, err := queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: superQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - depresultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: contextQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 2, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - resultid, err = queries.AddResult(ctx, &repository.AddResultParams{ - Queryid: jsonQueryID, - Value: "example_value", - Textentryid: textentry.ID, - Queryversion: 1, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: resultid, - Requiredresultid: depresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.False(t, isSynced) - - err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ - Resultid: depresultid, - Requiredresultid: superresultid, - }) - assert.NoError(t, err) - - isSynced, err = queries.IsClientSynced(ctx, clientId) - assert.NoError(t, err) - assert.True(t, isSynced) -} diff --git a/internal/database/repository/result_test.go b/internal/database/repository/result_test.go index 6639115e..a9b54393 100644 --- a/internal/database/repository/result_test.go +++ b/internal/database/repository/result_test.go @@ -95,7 +95,7 @@ func TestResults(t *testing.T) { assert.NoError(t, err) assert.False(t, issynced) - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: 1, Bucket: "hi", Key: "hello", @@ -107,9 +107,6 @@ func TestResults(t *testing.T) { assert.NoError(t, err) assert.True(t, issynced) - textentry, err := queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) - err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ Clientid: clientId, Queryid: jsonQueryID, @@ -127,7 +124,7 @@ func TestResults(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: jsonQueryID, Value: jsonResultValue, - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: 1, }) assert.NoError(t, err) @@ -254,20 +251,18 @@ func TestResultValues(t *testing.T) { Version: 1, }) assert.NoError(t, err) - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: 1, Bucket: "hi", Key: "hello", Cleanentryid: cleanid, }) assert.NoError(t, err) - textentry, err := queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) result := repository.AddResultParams{ Queryid: contextQueryID, Value: "context_value_1", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: contextQuery.Activeversion, } @@ -297,7 +292,7 @@ func TestResultValues(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: contextQueryID, Value: "context_value_2", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: contextQuery.Activeversion - 1, }) assert.NoError(t, err) @@ -318,7 +313,7 @@ func TestResultValues(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: contextQueryID, Value: "context_value_3", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: contextQuery.Activeversion, }) assert.NoError(t, err) @@ -339,7 +334,7 @@ func TestResultValues(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: jsonQueryID, Value: "json_value_1", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: jsonVersion, }) assert.NoError(t, err) @@ -463,7 +458,7 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { assert.NoError(t, err) assert.Len(t, qs, 0) - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: 1, Bucket: "hi", Key: "hello", @@ -471,9 +466,6 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { }) assert.NoError(t, err) - textentry, err := queries.GetTextEntryByDocId(ctx, documentID) - assert.NoError(t, err) - qs, err = queries.ListUnsyncedNoDepsQueriesByDocId(ctx, documentID) assert.NoError(t, err) assert.Len(t, qs, 1) @@ -485,7 +477,7 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: contextQueryID, Value: "context_value", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: 1, }) assert.NoError(t, err) @@ -501,7 +493,7 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: jsonQueryID, Value: "context_value", - Textentryid: textentry.ID, + Textentryid: textId, Queryversion: 1, }) assert.NoError(t, err) @@ -536,7 +528,7 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { assert.NoError(t, err) assert.Len(t, qs, 0) - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + textTwoId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: 1, Bucket: "hi", Key: "hello", @@ -544,13 +536,10 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { }) assert.NoError(t, err) - texttwoentry, err := queries.GetTextEntryByDocId(ctx, documentTwoID) - assert.NoError(t, err) - _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: contextQueryID, Value: "context_value", - Textentryid: texttwoentry.ID, + Textentryid: textTwoId, Queryversion: 1, }) assert.NoError(t, err) @@ -566,7 +555,7 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { _, err = queries.AddResult(ctx, &repository.AddResultParams{ Queryid: jsonQueryID, Value: "context_value", - Textentryid: texttwoentry.ID, + Textentryid: textTwoId, Queryversion: 1, }) assert.NoError(t, err) diff --git a/internal/database/repository/sync_test.go b/internal/database/repository/sync_test.go new file mode 100644 index 00000000..f27d81e1 --- /dev/null +++ b/internal/database/repository/sync_test.go @@ -0,0 +1,846 @@ +package repository_test + +import ( + "context" + "os" + "path" + "testing" + + "queryorchestration/internal/database/repository" + "queryorchestration/internal/serviceconfig" + "queryorchestration/internal/test" + + "github.com/stretchr/testify/assert" +) + +func TestListClientDocumentIDs(t *testing.T) { + if testing.Short() { + t.Skip("Skipping long test in short mode") + } + ctx := context.Background() + + cfg := &serviceconfig.BaseConfig{} + test.SetCfgProvider(t, cfg) + cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../..")) + _, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{ + Cfg: cfg, + RunMigrations: true, + }) + defer cleanup() + + queries := cfg.GetDBQueries() + + id, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) + assert.NoError(t, err) + + ids, err := queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ + Clientid: id, + Batchsize: 1, + Pageoffset: 0, + }) + assert.NoError(t, err) + assert.Len(t, ids, 0) + + docOne, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ + Clientid: id, + Hash: "example_hash", + }) + assert.NoError(t, err) + + ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ + Clientid: id, + Batchsize: 1, + Pageoffset: 0, + }) + assert.NoError(t, err) + assert.Len(t, ids, 1) + total := int64(1) + assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ + { + ID: docOne, + Totalcount: &total, + }, + }, ids) + + docTwo, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ + Clientid: id, + Hash: "example_hash_two", + }) + assert.NoError(t, err) + + ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ + Clientid: id, + Batchsize: 1, + Pageoffset: 0, + }) + assert.NoError(t, err) + assert.Len(t, ids, 1) + total = int64(2) + assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ + { + ID: docOne, + Totalcount: &total, + }, + }, ids) + + ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ + Clientid: id, + Batchsize: 1, + Pageoffset: 1, + }) + assert.NoError(t, err) + assert.Len(t, ids, 1) + assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ + { + ID: docTwo, + Totalcount: &total, + }, + }, ids) + + ids, err = queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ + Clientid: id, + Batchsize: 2, + Pageoffset: 0, + }) + assert.NoError(t, err) + assert.Len(t, ids, 2) + assert.ElementsMatch(t, []*repository.ListDocumentIDsBatchRow{ + { + ID: docOne, + Totalcount: &total, + }, + { + ID: docTwo, + Totalcount: &total, + }, + }, ids) +} + +func TestClientSync(t *testing.T) { + if testing.Short() { + t.Skip("Skipping long test in short mode") + } + ctx := context.Background() + + cfg := &serviceconfig.BaseConfig{} + test.SetCfgProvider(t, cfg) + cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../..")) + _, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{ + Cfg: cfg, + RunMigrations: true, + }) + defer cleanup() + + queries := cfg.GetDBQueries() + + contextQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeContextFull)) + assert.NoError(t, err) + contextQueryVersion, err := queries.AddLatestQueryVersion(ctx, contextQueryID) + assert.NoError(t, err) + err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ + Queryid: contextQueryID, + Versionid: contextQueryVersion, + }) + assert.NoError(t, err) + jsonQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor)) + assert.NoError(t, err) + jsonQueryVersion, err := queries.AddLatestQueryVersion(ctx, jsonQueryID) + assert.NoError(t, err) + err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ + Queryid: jsonQueryID, + Versionid: jsonQueryVersion, + }) + assert.NoError(t, err) + err = queries.AddRequiredQuery(ctx, &repository.AddRequiredQueryParams{ + Queryid: jsonQueryID, + Requiredqueryid: contextQueryID, + Addedversion: jsonQueryVersion, + }) + assert.NoError(t, err) + + externalId := "EXAMPLE" + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: externalId, + }) + assert.NoError(t, err) + + collectorVersion, err := queries.AddLatestCollectorVersion(ctx, clientId) + assert.NoError(t, err) + err = queries.SetActiveCollectorVersion(ctx, &repository.SetActiveCollectorVersionParams{ + Versionid: collectorVersion, + Clientid: clientId, + }) + assert.NoError(t, err) + err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ + Clientid: clientId, + Queryid: jsonQueryID, + Addedversion: collectorVersion, + Name: "first_key", + }) + assert.NoError(t, err) + + isSynced, err := queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + + bucket := "example_bucket" + + t.Run("document fail clean", func(t *testing.T) { + documentID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ + Clientid: clientId, + Hash: "example_noclean", + }) + assert.NoError(t, err) + + docExternal, err := queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_noclean", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + + cleanid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ + Documentid: documentID, + Fail: repository.NullCleanfailtype{ + Valid: true, + Cleanfailtype: repository.CleanfailtypeInvalidMimetype, + }, + }) + assert.NoError(t, err) + err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ + Cleanid: cleanid, + Version: 1, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_noclean", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + }) + + t.Run("valid extraction", func(t *testing.T) { + documentID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ + Clientid: clientId, + Hash: "example_hash", + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + + docExternal, err := queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + key := "example_key" + cleanId, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ + Documentid: documentID, + Bucket: &bucket, + Key: &key, + Mimetype: repository.NullCleanmimetype{ + Valid: true, + Cleanmimetype: repository.CleanmimetypeApplicationPdf, + }, + }) + assert.NoError(t, err) + err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ + Cleanid: cleanId, + Version: 1, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + Version: 1, + Bucket: "hi", + Key: "hello", + Cleanentryid: cleanId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + t.Run("document standard results", func(t *testing.T) { + contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: contextQueryID, + Value: "example_context", + Textentryid: textId, + Queryversion: contextQueryVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: jsonQueryID, + Value: "json_value", + Textentryid: textId, + Queryversion: jsonQueryVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: jsonResultId, + Requiredresultid: contextResultId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "json_value"}`), + }, docExternal) + }) + + contextLatestVersion, err := queries.AddLatestQueryVersion(ctx, contextQueryID) + assert.NoError(t, err) + err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ + Queryid: contextQueryID, + Versionid: contextLatestVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + t.Run("update upstream query", func(t *testing.T) { + contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: contextQueryID, + Value: "context_version_2", + Textentryid: textId, + Queryversion: contextLatestVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: jsonQueryID, + Value: "updated_context_value", + Textentryid: textId, + Queryversion: jsonQueryVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: jsonResultId, + Requiredresultid: contextResultId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "updated_context_value"}`), + }, docExternal) + }) + + t.Run("update text entry", func(t *testing.T) { + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + Version: 1, + Bucket: "hi", + Key: "hello", + Cleanentryid: cleanId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + contextResultID, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: contextQueryID, + Value: "updated_text_context", + Textentryid: textId, + Queryversion: 2, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + jsonResultID, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: jsonQueryID, + Value: "updated_text_json", + Textentryid: textId, + Queryversion: 1, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: jsonResultID, + Requiredresultid: contextResultID, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "updated_text_json"}`), + }, docExternal) + }) + t.Run("updated clean entry", func(t *testing.T) { + cleanthreeid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{ + Documentid: documentID, + Bucket: &bucket, + Key: &key, + Mimetype: repository.NullCleanmimetype{ + Valid: true, + Cleanmimetype: repository.CleanmimetypeApplicationPdf, + }, + }) + assert.NoError(t, err) + err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{ + Cleanid: cleanthreeid, + Version: 1, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + textThreeId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + Version: 1, + Bucket: "hi", + Key: "hello", + Cleanentryid: cleanthreeid, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: contextQueryID, + Value: "update_clean_context", + Textentryid: textThreeId, + Queryversion: contextLatestVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + jsonResultID, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: jsonQueryID, + Value: "update_clean_json", + Textentryid: textThreeId, + Queryversion: 1, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": null}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: jsonResultID, + Requiredresultid: contextResultId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "update_clean_json"}`), + }, docExternal) + + latestCollectorVersion, err := queries.AddLatestCollectorVersion(ctx, clientId) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "update_clean_json"}`), + }, docExternal) + + t.Run("update collector name", func(t *testing.T) { + err = queries.SetActiveCollectorVersion(ctx, &repository.SetActiveCollectorVersionParams{ + Versionid: latestCollectorVersion, + Clientid: clientId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"first_key": "update_clean_json"}`), + }, docExternal) + + err = queries.RemoveCollectorQuery(ctx, &repository.RemoveCollectorQueryParams{ + Clientid: clientId, + Queryid: jsonQueryID, + Removedversion: &latestCollectorVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{}`), + }, docExternal) + + err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ + Clientid: clientId, + Queryid: jsonQueryID, + Addedversion: latestCollectorVersion, + Name: "second_key", + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": "update_clean_json"}`), + }, docExternal) + }) + + t.Run("add existing query", func(t *testing.T) { + err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{ + Clientid: clientId, + Queryid: contextQueryID, + Addedversion: latestCollectorVersion, + Name: "example_key", + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": "update_clean_json", "example_key": "update_clean_context"}`), + }, docExternal) + }) + + t.Run("add super query", func(t *testing.T) { + superQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor)) + assert.NoError(t, err) + superQueryVersion, err := queries.AddLatestQueryVersion(ctx, superQueryID) + assert.NoError(t, err) + err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{ + Queryid: superQueryID, + Versionid: superQueryVersion, + }) + assert.NoError(t, err) + err = queries.AddRequiredQuery(ctx, &repository.AddRequiredQueryParams{ + Queryid: contextQueryID, + Requiredqueryid: superQueryID, + Addedversion: superQueryVersion, + }) + assert.NoError(t, err) + + superResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: superQueryID, + Value: "super_value", + Textentryid: textThreeId, + Queryversion: superQueryVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": null, "example_key": null}`), + }, docExternal) + + contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: contextQueryID, + Value: "context_with_super_value", + Textentryid: textThreeId, + Queryversion: contextLatestVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": null, "example_key": null}`), + }, docExternal) + + jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{ + Queryid: jsonQueryID, + Value: "json_with_super", + Textentryid: textThreeId, + Queryversion: jsonQueryVersion, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": null, "example_key": null}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: contextResultId, + Requiredresultid: superResultId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.False(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": null, "example_key": "context_with_super_value"}`), + }, docExternal) + + err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{ + Resultid: jsonResultId, + Requiredresultid: contextResultId, + }) + assert.NoError(t, err) + + isSynced, err = queries.IsClientSynced(ctx, clientId) + assert.NoError(t, err) + assert.True(t, isSynced) + docExternal, err = queries.GetDocumentExternal(ctx, documentID) + assert.NoError(t, err) + assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{ + ID: documentID, + Clientid: externalId, + Hash: "example_hash", + Fields: []byte(`{"second_key": "json_with_super", "example_key": "context_with_super_value"}`), + }, docExternal) + }) + }) + }) +} diff --git a/internal/database/repository/text.sql.go b/internal/database/repository/text.sql.go index e85103b7..295b9c1a 100644 --- a/internal/database/repository/text.sql.go +++ b/internal/database/repository/text.sql.go @@ -11,8 +11,8 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) -const addDocumentTextEntry = `-- name: AddDocumentTextEntry :exec -INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4) +const addDocumentTextEntry = `-- name: AddDocumentTextEntry :one +INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4) returning id ` type AddDocumentTextEntryParams struct { @@ -24,15 +24,17 @@ type AddDocumentTextEntryParams struct { // AddDocumentTextEntry // -// INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4) -func (q *Queries) AddDocumentTextEntry(ctx context.Context, arg *AddDocumentTextEntryParams) error { - _, err := q.db.Exec(ctx, addDocumentTextEntry, +// INSERT INTO documentTextExtractions (version, bucket, key, cleanEntryId) VALUES ($1, $2, $3, $4) returning id +func (q *Queries) AddDocumentTextEntry(ctx context.Context, arg *AddDocumentTextEntryParams) (pgtype.UUID, error) { + row := q.db.QueryRow(ctx, addDocumentTextEntry, arg.Version, arg.Bucket, arg.Key, arg.Cleanentryid, ) - return err + var id pgtype.UUID + err := row.Scan(&id) + return id, err } const getTextEntryByDocId = `-- name: GetTextEntryByDocId :one diff --git a/internal/database/repository/text_test.go b/internal/database/repository/text_test.go index ceeac194..e4c2c10e 100644 --- a/internal/database/repository/text_test.go +++ b/internal/database/repository/text_test.go @@ -67,13 +67,15 @@ func TestTextExtraction(t *testing.T) { assert.NoError(t, err) assert.False(t, isextract) - err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + textId, err := queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: 1, Bucket: bucket, Key: key, Cleanentryid: cleanid, }) assert.NoError(t, err) + assert.NotNil(t, textId) + assert.NotEqual(t, pgtype.UUID{}, textId) isextract, err = queries.IsDocumentTextExtracted(ctx, id) assert.NoError(t, err) @@ -85,6 +87,5 @@ func TestTextExtraction(t *testing.T) { assert.Equal(t, bucket, text.Bucket) assert.Equal(t, key, text.Key) assert.Equal(t, int64(1), text.Version) - assert.NotEqual(t, pgtype.UUID{}, text.ID) - assert.True(t, text.ID.Valid) + assert.Equal(t, textId, text.ID) } diff --git a/internal/document/clean/clean.go b/internal/document/clean/clean.go index 2155b579..c84afe47 100644 --- a/internal/document/clean/clean.go +++ b/internal/document/clean/clean.go @@ -90,7 +90,7 @@ func (s *Service) clean(ctx context.Context, id uuid.UUID) error { slog.Debug("cleaning document", "id", id.String()) docId := database.MustToDBUUID(id) - doc, err := s.cfg.GetDBQueries().GetDocument(ctx, docId) + doc, err := s.cfg.GetDBQueries().GetDocumentSummary(ctx, docId) if err != nil { return err } diff --git a/internal/document/clean/clean_test.go b/internal/document/clean/clean_test.go index a251876c..4bdc5f14 100644 --- a/internal/document/clean/clean_test.go +++ b/internal/document/clean/clean_test.go @@ -35,7 +35,7 @@ func TestClean(t *testing.T) { cfg: cfg, } - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", @@ -46,7 +46,7 @@ func TestClean(t *testing.T) { } dbid := database.MustToDBUUID(doc.ID) - pool.ExpectQuery("name: GetDocument :one").WithArgs(dbid). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(dbid). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(dbid, database.MustToDBUUID(doc.ClientID), doc.Hash), @@ -173,7 +173,7 @@ func TestStoreClean(t *testing.T) { cfg: cfg, } - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), } inloc := document.Location{ diff --git a/internal/document/clean/create_test.go b/internal/document/clean/create_test.go index a459c13d..2becd532 100644 --- a/internal/document/clean/create_test.go +++ b/internal/document/clean/create_test.go @@ -50,7 +50,7 @@ func TestCreate(t *testing.T) { cfg: cfg, } - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", @@ -65,7 +65,7 @@ func TestCreate(t *testing.T) { pgxmock.NewRows([]string{"isclean"}). AddRow(false), ) - pool.ExpectQuery("name: GetDocument :one").WithArgs(dbid). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(dbid). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(dbid, database.MustToDBUUID(doc.ClientID), doc.Hash), diff --git a/internal/document/get.go b/internal/document/get.go index 02566fa7..05deff9e 100644 --- a/internal/document/get.go +++ b/internal/document/get.go @@ -2,21 +2,42 @@ package document import ( "context" + "encoding/json" "queryorchestration/internal/database" "github.com/google/uuid" ) -func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Document, error) { - doc, err := s.cfg.GetDBQueries().GetDocument(ctx, database.MustToDBUUID(id)) +func (s *Service) GetSummary(ctx context.Context, id uuid.UUID) (*DocumentSummary, error) { + doc, err := s.cfg.GetDBQueries().GetDocumentSummary(ctx, database.MustToDBUUID(id)) if err != nil { return nil, err } - return &Document{ + return &DocumentSummary{ ID: database.MustToUUID(doc.ID), ClientID: database.MustToUUID(doc.Clientid), Hash: doc.Hash, }, nil } + +func (s *Service) GetExternal(ctx context.Context, id uuid.UUID) (*DocumentExternal, error) { + doc, err := s.cfg.GetDBQueries().GetDocumentExternal(ctx, database.MustToDBUUID(id)) + if err != nil { + return nil, err + } + + var fields map[string]interface{} + err = json.Unmarshal(doc.Fields, &fields) + if err != nil { + return nil, err + } + + return &DocumentExternal{ + Id: database.MustToUUID(doc.ID), + ClientID: doc.Clientid, + Hash: doc.Hash, + Fields: fields, + }, nil +} diff --git a/internal/document/get_test.go b/internal/document/get_test.go index 04dbada6..a40d6de0 100644 --- a/internal/document/get_test.go +++ b/internal/document/get_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestGet(t *testing.T) { +func TestGetSummary(t *testing.T) { ctx := context.Background() pool, err := pgxmock.NewPool() @@ -27,19 +27,50 @@ func TestGet(t *testing.T) { svc := document.New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", } - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(doc.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(doc.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(doc.ID), database.MustToDBUUID(doc.ClientID), doc.Hash), ) - adoc, err := svc.Get(ctx, doc.ID) + adoc, err := svc.GetSummary(ctx, doc.ID) + assert.NoError(t, err) + assert.Equal(t, &doc, adoc) +} + +func TestGetExternal(t *testing.T) { + ctx := context.Background() + + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &serviceconfig.BaseConfig{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + + svc := document.New(cfg) + + doc := document.DocumentExternal{ + Id: uuid.New(), + ClientID: "externalID", + Hash: "example", + Fields: map[string]interface{}{ + "json": "hello", + }, + } + + pool.ExpectQuery("name: GetDocumentExternal :one").WithArgs(database.MustToDBUUID(doc.Id)). + WillReturnRows( + pgxmock.NewRows([]string{"id", "clientId", "hash", "fields"}). + AddRow(database.MustToDBUUID(doc.Id), "externalID", "example", []byte(`{"json": "hello"}`)), + ) + + adoc, err := svc.GetExternal(ctx, doc.Id) assert.NoError(t, err) assert.Equal(t, &doc, adoc) } diff --git a/internal/document/init/create_test.go b/internal/document/init/create_test.go index dccf49bc..0825f071 100644 --- a/internal/document/init/create_test.go +++ b/internal/document/init/create_test.go @@ -35,7 +35,7 @@ func TestCreate(t *testing.T) { svc := New(cfg) clientId := uuid.New() - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: clientId, Hash: "example_hash", @@ -57,7 +57,7 @@ func TestCreate(t *testing.T) { pool.ExpectExec("name: AddDocumentEntry :exec").WithArgs(database.MustToDBUUID(doc.ID), location.Bucket, location.Key). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(doc.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(doc.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(doc.ID), database.MustToDBUUID(doc.ClientID), doc.Hash), @@ -101,7 +101,7 @@ func TestGetCreateParams(t *testing.T) { svc := New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ClientID: uuid.New(), Hash: "example_hash", } @@ -138,7 +138,7 @@ func TestGetCreateParamsExisting(t *testing.T) { svc := New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", @@ -179,7 +179,7 @@ func TestGetCreateParamsCurrentDocErr(t *testing.T) { svc := New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ClientID: uuid.New(), Hash: "example_hash", } @@ -209,7 +209,7 @@ func TestSubmitCreate(t *testing.T) { svc := New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", @@ -249,7 +249,7 @@ func TestSubmitCreateExists(t *testing.T) { svc := New(cfg) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: uuid.New(), Hash: "example_hash", diff --git a/internal/document/list.go b/internal/document/list.go index 6855d2c6..18969b73 100644 --- a/internal/document/list.go +++ b/internal/document/list.go @@ -4,28 +4,19 @@ import ( "context" "queryorchestration/internal/database" - - "github.com/google/uuid" ) -type DocumentInList struct { - ID uuid.UUID - Bucket string - Key string -} - -func (s *Service) ListByClientExternalId(ctx context.Context, id string) ([]*DocumentInList, error) { +func (s *Service) ListByClientExternalId(ctx context.Context, id string) ([]*DocumentSummary, error) { documents, err := s.cfg.GetDBQueries().ListDocumentsByClientExternalId(ctx, id) if err != nil { return nil, err } - docs := make([]*DocumentInList, len(documents)) + docs := make([]*DocumentSummary, len(documents)) for i, doc := range documents { - docs[i] = &DocumentInList{ - ID: database.MustToUUID(doc.ID), - Bucket: doc.Bucket, - Key: doc.Key, + docs[i] = &DocumentSummary{ + ID: database.MustToUUID(doc.ID), + Hash: doc.Hash, } } diff --git a/internal/document/list_test.go b/internal/document/list_test.go index 7eceef16..14b81696 100644 --- a/internal/document/list_test.go +++ b/internal/document/list_test.go @@ -27,18 +27,17 @@ func TestListByClientId(t *testing.T) { svc := document.New(cfg) clientId := "externalId" - doc := []*document.DocumentInList{ + doc := []*document.DocumentSummary{ { - ID: uuid.New(), - Bucket: "bucketone", - Key: "keyone", + ID: uuid.New(), + Hash: "bucketone", }, } pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId). WillReturnRows( - pgxmock.NewRows([]string{"id", "bucket", "key"}). - AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Bucket, doc[0].Key), + pgxmock.NewRows([]string{"id", "hash"}). + AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Hash), ) adoc, err := svc.ListByClientExternalId(ctx, clientId) diff --git a/internal/document/service.go b/internal/document/service.go index 293e2737..bd1834f5 100644 --- a/internal/document/service.go +++ b/internal/document/service.go @@ -11,12 +11,19 @@ type Location struct { Key string } -type Document struct { +type DocumentSummary struct { ID uuid.UUID ClientID uuid.UUID Hash string } +type DocumentExternal struct { + Id uuid.UUID + ClientID string + Hash string + Fields map[string]interface{} +} + type Service struct { cfg serviceconfig.ConfigProvider } diff --git a/internal/document/sync/sync.go b/internal/document/sync/sync.go index d32da877..48ac9899 100644 --- a/internal/document/sync/sync.go +++ b/internal/document/sync/sync.go @@ -11,7 +11,7 @@ import ( ) func (s *Service) Sync(ctx context.Context, id uuid.UUID) error { - doc, err := s.svc.Document.Get(ctx, id) + doc, err := s.svc.Document.GetSummary(ctx, id) if err != nil { return err } diff --git a/internal/document/sync/sync_test.go b/internal/document/sync/sync_test.go index dd73beba..caa2c1b8 100644 --- a/internal/document/sync/sync_test.go +++ b/internal/document/sync/sync_test.go @@ -42,13 +42,13 @@ func TestSync(t *testing.T) { ID: uuid.New(), CanSync: true, } - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), ClientID: j.ID, Hash: "example_hash", } - pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(doc.ID)). + pool.ExpectQuery("name: GetDocumentSummary :one").WithArgs(database.MustToDBUUID(doc.ID)). WillReturnRows( pgxmock.NewRows([]string{"id", "clientId", "hash"}). AddRow(database.MustToDBUUID(doc.ID), database.MustToDBUUID(doc.ClientID), doc.Hash), diff --git a/internal/document/text/create_test.go b/internal/document/text/create_test.go index 694efc6e..dd0949fc 100644 --- a/internal/document/text/create_test.go +++ b/internal/document/text/create_test.go @@ -68,8 +68,11 @@ func TestCreate(t *testing.T) { pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "mimetype", "fail"}). AddRow(cleanId, database.MustToDBUUID(id), &inloc.Bucket, &inloc.Key, int32(1), dbmimetype, repository.NullCleanfailtype{}), ) - pool.ExpectExec("name: AddDocumentTextEntry :exec").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, cleanId). - WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectQuery("name: AddDocumentTextEntry :one").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, cleanId). + WillReturnRows( + pgxmock.NewRows([]string{"id"}). + AddRow(database.MustToDBUUID(uuid.New())), + ) mockSQS.EXPECT(). SendMessage( diff --git a/internal/document/text/extract.go b/internal/document/text/extract.go index bf4eea6a..724ace95 100644 --- a/internal/document/text/extract.go +++ b/internal/document/text/extract.go @@ -34,7 +34,7 @@ func (s *Service) extract(ctx context.Context, cleanId uuid.UUID) error { version := build.GetVersionUnixTimestamp() - err = s.cfg.GetDBQueries().AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ + _, err = s.cfg.GetDBQueries().AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{ Version: version, Bucket: outLocation.Bucket, Key: outLocation.Key, diff --git a/internal/document/text/extract_test.go b/internal/document/text/extract_test.go index 0b8536ce..86f1455a 100644 --- a/internal/document/text/extract_test.go +++ b/internal/document/text/extract_test.go @@ -46,8 +46,11 @@ func TestExtract(t *testing.T) { pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "mimetype", "fail"}). AddRow(dbCleanId, database.MustToDBUUID(id), &inloc.Bucket, &inloc.Key, int64(1), dbmimetype, repository.NullCleanfailtype{}), ) - pool.ExpectExec("name: AddDocumentTextEntry :exec").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, dbCleanId). - WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectQuery("name: AddDocumentTextEntry :one").WithArgs(pgxmock.AnyArg(), inloc.Bucket, inloc.Key, dbCleanId). + WillReturnRows( + pgxmock.NewRows([]string{"id"}). + AddRow(database.MustToDBUUID(uuid.New())), + ) err = svc.extract(ctx, cleanId) assert.NoError(t, err) diff --git a/internal/query/test/test_test.go b/internal/query/test/test_test.go index cbb98ceb..587b5c7f 100644 --- a/internal/query/test/test_test.go +++ b/internal/query/test/test_test.go @@ -39,7 +39,7 @@ func TestTest(t *testing.T) { }), }) - doc := document.Document{ + doc := document.DocumentSummary{ ID: uuid.New(), } params := &result.Process{ diff --git a/internal/server/service/listener.go b/internal/server/api/listener.go similarity index 99% rename from internal/server/service/listener.go rename to internal/server/api/listener.go index 68a2f820..48789cbe 100644 --- a/internal/server/service/listener.go +++ b/internal/server/api/listener.go @@ -1,4 +1,4 @@ -package service +package api import ( "context" diff --git a/internal/server/service/listener_test.go b/internal/server/api/listener_test.go similarity index 99% rename from internal/server/service/listener_test.go rename to internal/server/api/listener_test.go index 240ee8be..c37c9d98 100644 --- a/internal/server/service/listener_test.go +++ b/internal/server/api/listener_test.go @@ -1,4 +1,4 @@ -package service +package api import ( "context" diff --git a/internal/server/service/swagger.go b/internal/server/api/swagger.go similarity index 97% rename from internal/server/service/swagger.go rename to internal/server/api/swagger.go index 5631cf12..871f1425 100644 --- a/internal/server/service/swagger.go +++ b/internal/server/api/swagger.go @@ -1,4 +1,4 @@ -package service +package api import ( "net/http" diff --git a/internal/server/service/swagger_test.go b/internal/server/api/swagger_test.go similarity index 86% rename from internal/server/service/swagger_test.go rename to internal/server/api/swagger_test.go index c41bf0ad..46127d1b 100644 --- a/internal/server/service/swagger_test.go +++ b/internal/server/api/swagger_test.go @@ -1,4 +1,4 @@ -package service +package api import ( "net/http" @@ -6,7 +6,7 @@ import ( "strings" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" @@ -14,7 +14,7 @@ import ( ) func TestGetSwaggerJSONFunc(t *testing.T) { - openapi, err := queryservice.GetSwagger() + openapi, err := queryapi.GetSwagger() require.NoError(t, err) f, err := getSwaggerJSONFunc(openapi) @@ -31,7 +31,7 @@ func TestGetSwaggerJSONFunc(t *testing.T) { } func TestGetSwaggerYAMLFunc(t *testing.T) { - openapi, err := queryservice.GetSwagger() + openapi, err := queryapi.GetSwagger() require.NoError(t, err) f, err := getSwaggerYAMLFunc(openapi) diff --git a/internal/serviceconfig/observability/prometheus/prometheus.md b/internal/serviceconfig/observability/prometheus/prometheus.md index 724a48e3..549d5f05 100644 --- a/internal/serviceconfig/observability/prometheus/prometheus.md +++ b/internal/serviceconfig/observability/prometheus/prometheus.md @@ -9,7 +9,7 @@ Then you can run your service that exposed the metrics. ## Testing the API service Start the API server on the host like -`PGPORT=5430 go run ./cmd/queryService` +`PGPORT=5430 go run ./cmd/queryAPI` Once started you will be able to see the raw metrics at http://localhost:8080/metrics diff --git a/internal/serviceconfig/queue/clientsync/config.go b/internal/serviceconfig/queue/clientsync/config.go index a8267675..5ec04d58 100644 --- a/internal/serviceconfig/queue/clientsync/config.go +++ b/internal/serviceconfig/queue/clientsync/config.go @@ -1,5 +1,7 @@ package clientsync +const EnvName = "CLIENT_SYNC_URL" + type ClientSyncConfig struct { ClientSyncURL string `env:"CLIENT_SYNC_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/documentclean/config.go b/internal/serviceconfig/queue/documentclean/config.go index 895668ba..e9af4ce5 100644 --- a/internal/serviceconfig/queue/documentclean/config.go +++ b/internal/serviceconfig/queue/documentclean/config.go @@ -1,5 +1,7 @@ package documentclean +const EnvName = "DOCUMENT_CLEAN_URL" + type DocCleanConfig struct { DocumentCleanURL string `env:"DOCUMENT_CLEAN_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/documentinit/config.go b/internal/serviceconfig/queue/documentinit/config.go index e81cede9..ac2ddb0e 100644 --- a/internal/serviceconfig/queue/documentinit/config.go +++ b/internal/serviceconfig/queue/documentinit/config.go @@ -1,5 +1,7 @@ package documentinit +const EnvName = "DOCUMENT_INIT_URL" + type DocInitConfig struct { DocInitURL string `env:"DOCUMENT_INIT_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/documentsync/config.go b/internal/serviceconfig/queue/documentsync/config.go index 8f804538..83227cd8 100644 --- a/internal/serviceconfig/queue/documentsync/config.go +++ b/internal/serviceconfig/queue/documentsync/config.go @@ -1,5 +1,7 @@ package documentsync +const EnvName = "DOCUMENT_SYNC_URL" + type DocSyncConfig struct { DocumentSyncURL string `env:"DOCUMENT_SYNC_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/documenttext/config.go b/internal/serviceconfig/queue/documenttext/config.go index 9f4d7f6c..cd12b180 100644 --- a/internal/serviceconfig/queue/documenttext/config.go +++ b/internal/serviceconfig/queue/documenttext/config.go @@ -1,5 +1,7 @@ package documenttext +const EnvName = "DOCUMENT_TEXT_URL" + type DocTextConfig struct { DocumentTextURL string `env:"DOCUMENT_TEXT_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/query/config.go b/internal/serviceconfig/queue/query/config.go index 0c7e5544..0744f2dc 100644 --- a/internal/serviceconfig/queue/query/config.go +++ b/internal/serviceconfig/queue/query/config.go @@ -1,5 +1,7 @@ package query +const EnvName = "QUERY_URL" + type QueryConfig struct { QueryURL string `env:"QUERY_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/querysync/config.go b/internal/serviceconfig/queue/querysync/config.go index fa0cc323..ca17c898 100644 --- a/internal/serviceconfig/queue/querysync/config.go +++ b/internal/serviceconfig/queue/querysync/config.go @@ -1,5 +1,7 @@ package querysync +const EnvName = "QUERY_SYNC_URL" + type QuerySyncConfig struct { QuerySyncURL string `env:"QUERY_SYNC_URL,required,notEmpty"` } diff --git a/internal/serviceconfig/queue/queryversionsync/config.go b/internal/serviceconfig/queue/queryversionsync/config.go index 5c140330..88db2da4 100644 --- a/internal/serviceconfig/queue/queryversionsync/config.go +++ b/internal/serviceconfig/queue/queryversionsync/config.go @@ -1,5 +1,7 @@ package queryversionsync +const EnvName = "QUERY_VERSION_SYNC_URL" + type QueryVersionSyncConfig struct { QueryVersionSyncURL string `env:"QUERY_VERSION_SYNC_URL,required,notEmpty"` } diff --git a/internal/test/service.go b/internal/test/api.go similarity index 51% rename from internal/test/service.go rename to internal/test/api.go index 391055e8..9d91aa41 100644 --- a/internal/test/service.go +++ b/internal/test/api.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - queryservice "queryorchestration/api/queryService" + queryapi "queryorchestration/api/queryAPI" "queryorchestration/internal/serviceconfig" "github.com/docker/go-connections/nat" @@ -13,29 +13,33 @@ import ( "github.com/testcontainers/testcontainers-go" ) -type Service = string +type APIName = string const ( - QueryService = queryservice.Name + QueryAPIName APIName = queryapi.Name ) -type ServiceConfig struct { - Name Service - Cfg serviceconfig.ConfigProvider - Network *testcontainers.DockerNetwork - Env map[string]string +type API struct { + Name APIName + DownstreamQueues []RunnerName } -func CreateService(t testing.TB, ctx context.Context, config *ServiceConfig) (*Container, func()) { +type APIConfig struct { + API API + Cfg serviceconfig.ConfigProvider + Network *testcontainers.DockerNetwork +} + +func CreateAPI(t testing.TB, ctx context.Context, config *APIConfig) (*Container, func()) { port, err := nat.NewPort("tcp", "8080") require.NoError(t, err) container, cleanup := createContainer(t, ctx, &containerConfig{ - Cfg: config.Cfg, - Name: config.Name, - Network: config.Network, - Env: config.Env, - WaitForMsg: "⇨ http server started on [::]:8080", + Cfg: config.Cfg, + Name: config.API.Name, + DownstreamQueues: config.API.DownstreamQueues, + Network: config.Network, + WaitForMsg: "⇨ http server started on [::]:8080", }) host, err := container.Host(ctx) @@ -50,3 +54,15 @@ func CreateService(t testing.TB, ctx context.Context, config *ServiceConfig) (*C Container: container, }, cleanup } + +var QueryAPI = API{ + Name: QueryAPIName, + DownstreamQueues: []RunnerName{ + ClientSyncRunnerName, + QueryVersionSyncRunnerName, + }, +} + +var apis = []API{ + QueryAPI, +} diff --git a/internal/test/service_test.go b/internal/test/api_test.go similarity index 71% rename from internal/test/service_test.go rename to internal/test/api_test.go index 8be68899..08663023 100644 --- a/internal/test/service_test.go +++ b/internal/test/api_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCreateService(t *testing.T) { +func TestCreateAPI(t *testing.T) { if testing.Short() { t.Skip("Skipping long test in short mode") } @@ -30,17 +30,13 @@ func TestCreateService(t *testing.T) { }) defer dbcleanup() - acfg := &test.ServiceConfig{ - Name: test.QueryService, + acfg := &test.APIConfig{ + API: test.QueryAPI, Cfg: cfg, Network: ncfg, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "/here/there/every/where", - }, } - conn, cleanup := test.CreateService(t, ctx, acfg) + conn, cleanup := test.CreateAPI(t, ctx, acfg) assert.NotNil(t, conn) assert.NotNil(t, cleanup) diff --git a/internal/test/container.go b/internal/test/container.go index a0e6d2ca..0cb0d17d 100644 --- a/internal/test/container.go +++ b/internal/test/container.go @@ -22,12 +22,13 @@ type Container struct { } type containerConfig struct { - Name string - Cfg serviceconfig.ConfigProvider - Network *testcontainers.DockerNetwork - Env map[string]string - WaitForMsg string - ExposedPorts []nat.Port + Name string + Cfg serviceconfig.ConfigProvider + Network *testcontainers.DockerNetwork + DownstreamQueues []RunnerName + Env map[string]string + WaitForMsg string + ExposedPorts []nat.Port } func createContainer(t testing.TB, ctx context.Context, cfg *containerConfig) (testcontainers.Container, func()) { @@ -53,6 +54,10 @@ func createContainer(t testing.TB, ctx context.Context, cfg *containerConfig) (t } } + for _, e := range cfg.DownstreamQueues { + env[GetRunnerEnvFromName(e)] = GetQueueURL(cfg.Cfg, e) + } + req := testcontainers.ContainerRequest{ Image: "queryorchestration:latest", Env: env, diff --git a/internal/test/container_test.go b/internal/test/container_test.go index b4678eaf..c40cd092 100644 --- a/internal/test/container_test.go +++ b/internal/test/container_test.go @@ -29,12 +29,10 @@ func TestCreateContainer(t *testing.T) { defer dbcleanup() ccfg := &containerConfig{ - Name: QueryService, - Cfg: cfg, - Network: ncfg, - Env: map[string]string{ - "EXAMPLE": "value", - }, + Name: QueryAPIName, + DownstreamQueues: QueryAPI.DownstreamQueues, + Cfg: cfg, + Network: ncfg, ExposedPorts: []nat.Port{ nat.Port("8080/tcp"), }, diff --git a/internal/test/ecosystem.go b/internal/test/ecosystem.go index 4e63cec3..283ad396 100644 --- a/internal/test/ecosystem.go +++ b/internal/test/ecosystem.go @@ -10,107 +10,12 @@ import ( "queryorchestration/internal/serviceconfig/aws" "queryorchestration/internal/serviceconfig/database" "queryorchestration/internal/serviceconfig/objectstore" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" ) -type EcosystemConfig struct { - Services map[Service]*Container - Runners map[Runner]*Container - Cfg serviceconfig.ConfigProvider -} - -type EcosystemNetworkConfig struct { - Runners []*RunnerNetworkConfig - Services []*ServiceNetworkConfig - Cfg serviceconfig.ConfigProvider - Dependencies *Dependencies -} - -func CreateRunnersAndServicesNetwork(t testing.TB, ctx context.Context, ncfg *EcosystemNetworkConfig) (*EcosystemConfig, func()) { - if ncfg.Dependencies == nil { - ncfg.Dependencies = &Dependencies{} - } - - network := ncfg.Dependencies.Network - var ncleanup func() - if network == nil { - network, ncleanup = CreateNetwork(t, ctx) - } - - _, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{ - Network: network, - Cfg: ncfg.Cfg, - RunMigrations: true, - }) - - ss := make(map[string]*Container, len(ncfg.Services)) - sclean := make([]func(), len(ncfg.Services)) - for i, s := range ncfg.Services { - c, ccleanup := CreateService(t, ctx, &ServiceConfig{ - Name: s.Name, - Env: s.Env, - Cfg: ncfg.Cfg, - Network: network, - }) - ss[s.Name] = c - sclean[i] = ccleanup - } - - var qcleanup func() - if ncfg.Dependencies.AWSConfig == nil { - _, qcleanup = CreateAWSContainer(t, ctx, &CreateAWSConfig{ - Network: network, - Cfg: ncfg.Cfg, - }) - } - - if ncfg.Cfg.GetQueueClient() == nil { - SetQueueClient(t, ctx, ncfg.Cfg) - } - - qs := make(map[string]*Container, len(ncfg.Runners)) - qclean := make([]func(), len(ncfg.Runners)) - for i, r := range ncfg.Runners { - url := ncfg.Dependencies.QueueURLs[r.Name] - if url == "" { - url = CreateQueue(t, ctx, ncfg.Cfg, r.Name) - } - - c, ccleanup := CreateRunner(t, ctx, &RunnerConfig{ - Name: r.Name, - Env: r.Env, - QueueURL: url, - Cfg: ncfg.Cfg, - Network: network, - }) - - qs[r.Name] = c - qclean[i] = ccleanup - } - - return &EcosystemConfig{ - Services: ss, - Runners: qs, - }, func() { - for _, c := range sclean { - c() - } - for _, c := range qclean { - c() - } - dbcleanup() - if qcleanup != nil { - qcleanup() - } - if ncleanup != nil { - ncleanup() - } - } -} - func SetCfgProviderWithBasePath(t testing.TB, cfg serviceconfig.ConfigProvider, basePath string) { SetCfgProvider(t, cfg) @@ -142,11 +47,10 @@ func SetCfgProvider(t testing.TB, cfg serviceconfig.ConfigProvider) { type ServiceNetworkConfig struct { Cfg serviceconfig.ConfigProvider Network *testcontainers.DockerNetwork - Name Runner - Env map[string]string + API API } -func CreateServiceNetwork(t testing.TB, ctx context.Context, scfg *ServiceNetworkConfig) (*Container, func()) { +func CreateAPINetwork(t testing.TB, ctx context.Context, scfg *ServiceNetworkConfig) (*Container, func()) { if scfg.Cfg == nil { scfg.Cfg = &serviceconfig.BaseConfig{} SetCfgProvider(t, scfg.Cfg) @@ -163,9 +67,8 @@ func CreateServiceNetwork(t testing.TB, ctx context.Context, scfg *ServiceNetwor Cfg: scfg.Cfg, }) - c, ccleanup := CreateService(t, ctx, &ServiceConfig{ - Name: scfg.Name, - Env: scfg.Env, + c, ccleanup := CreateAPI(t, ctx, &APIConfig{ + API: scfg.API, Cfg: scfg.Cfg, Network: network, }) @@ -179,66 +82,6 @@ func CreateServiceNetwork(t testing.TB, ctx context.Context, scfg *ServiceNetwor } } -type RunnerNetworkConfig struct { - Network *testcontainers.DockerNetwork - AWSContainer *AWSContainerConfig - QueueURL *string - Cfg serviceconfig.ConfigProvider - Name Runner - Env map[string]string -} - -func CreateRunnerNetwork(t testing.TB, ctx context.Context, rcfg *RunnerNetworkConfig) (*Container, func()) { - network := rcfg.Network - var ncleanup func() - if network == nil { - network, ncleanup = CreateNetwork(t, ctx) - } - - var qcleanup func() - if rcfg.AWSContainer == nil { - _, qcleanup = CreateAWSContainer(t, ctx, &CreateAWSConfig{ - Network: network, - Cfg: rcfg.Cfg, - }) - } - - if rcfg.Cfg.GetQueueClient() == nil { - err := rcfg.Cfg.SetQueueClient(ctx) - require.NoError(t, err) - } - - url := rcfg.QueueURL - if url == nil { - u := CreateQueue(t, ctx, rcfg.Cfg, rcfg.Name) - url = &u - } - - _, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{ - Network: network, - Cfg: rcfg.Cfg, - }) - - c, ccleanup := CreateRunner(t, ctx, &RunnerConfig{ - Name: rcfg.Name, - Env: rcfg.Env, - QueueURL: *url, - Cfg: rcfg.Cfg, - Network: network, - }) - - return c, func() { - ccleanup() - dbcleanup() - if qcleanup != nil { - qcleanup() - } - if ncleanup != nil { - ncleanup() - } - } -} - type FullDependenciesConfig interface { serviceconfig.ConfigProvider objectstore.ConfigProvider @@ -254,121 +97,90 @@ type Dependencies struct { func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) (Dependencies, func()) { network, ncleanup := CreateNetwork(t, ctx) - acfg, clean := CreateAWSContainer(t, ctx, &CreateAWSConfig{ + acfg, awsclean := CreateAWSContainer(t, ctx, &CreateAWSConfig{ Cfg: cfg, Network: network, }) + _, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{ + Network: network, + Cfg: cfg, + RunMigrations: true, + }) + SetQueueClient(t, ctx, cfg) SetStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) urls := map[string]string{} - urls[DocInitRunner] = CreateQueue(t, ctx, cfg, DocInitRunner) - urls[DocSyncRunner] = CreateQueue(t, ctx, cfg, DocSyncRunner) - urls[DocCleanRunner] = CreateQueue(t, ctx, cfg, DocCleanRunner) - urls[DocTextRunner] = CreateQueue(t, ctx, cfg, DocTextRunner) - urls[QuerySyncRunner] = CreateQueue(t, ctx, cfg, QuerySyncRunner) - urls[QueryRunner] = CreateQueue(t, ctx, cfg, QueryRunner) - urls[ClientSyncRunner] = CreateQueue(t, ctx, cfg, ClientSyncRunner) - urls[QueryVersionSyncRunner] = CreateQueue(t, ctx, cfg, QueryVersionSyncRunner) + for _, runner := range runners { + urls[runner.Name] = CreateQueue(t, ctx, cfg, runner.Name) + } - bucketName := "docinitbucket" - CreateBucket(t, ctx, cfg, bucketName) - SetBucketNotifs(t, ctx, cfg, bucketName) + CreateBucket(t, ctx, cfg, BucketName) + SetBucketNotifs(t, ctx, cfg, BucketName) return Dependencies{ - BucketName: bucketName, + BucketName: BucketName, QueueURLs: urls, Network: network, AWSConfig: acfg, }, func() { + awsclean() + dbcleanup() ncleanup() - clean() } } type Network struct { Dependencies Dependencies - Network EcosystemConfig - Client *queryservice.ClientWithResponses + APIs map[string]*Container + Runners map[string]*Container + Client *queryapi.ClientWithResponses } func CreateFullNetwork(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) (Network, func()) { deps, clean := CreateFullDependencies(t, ctx, cfg) - net, cleanup := CreateRunnersAndServicesNetwork(t, ctx, &EcosystemNetworkConfig{ - Cfg: cfg, - Dependencies: &deps, - Runners: []*RunnerNetworkConfig{ - { - Name: DocInitRunner, - Env: map[string]string{ - "DOCUMENT_SYNC_URL": deps.QueueURLs[DocSyncRunner], - }, - }, - { - Name: DocSyncRunner, - Env: map[string]string{ - "DOCUMENT_CLEAN_URL": deps.QueueURLs[DocCleanRunner], - }, - }, - { - Name: DocCleanRunner, - Env: map[string]string{ - "DOCUMENT_TEXT_URL": deps.QueueURLs[DocTextRunner], - }, - }, - { - Name: DocTextRunner, - Env: map[string]string{ - "QUERY_SYNC_URL": deps.QueueURLs[QuerySyncRunner], - }, - }, - { - Name: QuerySyncRunner, - Env: map[string]string{ - "QUERY_URL": deps.QueueURLs[QueryRunner], - }, - }, - { - Name: QueryRunner, - Env: map[string]string{ - "QUERY_URL": deps.QueueURLs[QueryRunner], - }, - }, - { - Name: ClientSyncRunner, - Env: map[string]string{ - "DOCUMENT_SYNC_URL": deps.QueueURLs[DocSyncRunner], - }, - }, - { - Name: QueryVersionSyncRunner, - Env: map[string]string{ - "CLIENT_SYNC_URL": deps.QueueURLs[ClientSyncRunner], - }, - }, - }, - Services: []*ServiceNetworkConfig{ - { - Name: QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": deps.QueueURLs[ClientSyncRunner], - "QUERY_VERSION_SYNC_URL": deps.QueueURLs[QueryVersionSyncRunner], - }, - }, - }, - }) + apiContainers := make(map[string]*Container, len(apis)) + apiClean := make([]func(), len(apis)) + for i, s := range apis { + c, ccleanup := CreateAPI(t, ctx, &APIConfig{ + API: s, + Cfg: cfg, + Network: deps.Network, + }) + apiContainers[s.Name] = c + apiClean[i] = ccleanup + } - qService, err := queryservice.NewClientWithResponses(net.Services[QueryService].URI) + qService, err := queryapi.NewClientWithResponses(apiContainers[QueryAPIName].URI) require.NoError(t, err) + runnerContainers := make(map[string]*Container, len(runners)) + runnerClean := make([]func(), len(runners)) + for i, r := range runners { + c, ccleanup := CreateRunner(t, ctx, &RunnerConfig{ + Runner: r, + Cfg: cfg, + Network: deps.Network, + }) + + runnerContainers[r.Name] = c + runnerClean[i] = ccleanup + } + return Network{ Dependencies: deps, - Network: *net, + APIs: apiContainers, + Runners: runnerContainers, Client: qService, }, func() { - cleanup() + for _, c := range apiClean { + c() + } + for _, c := range runnerClean { + c() + } clean() } } diff --git a/internal/test/ecosystem_test.go b/internal/test/ecosystem_test.go index b41ceb53..758f7033 100644 --- a/internal/test/ecosystem_test.go +++ b/internal/test/ecosystem_test.go @@ -10,76 +10,14 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCreateRunnerNetwork(t *testing.T) { +func TestCreateAPINetwork(t *testing.T) { if testing.Short() { t.Skip("Skipping long test in short mode") } ctx := context.Background() - cfg := &serviceconfig.BaseConfig{} - SetCfgProvider(t, cfg) - conn, cleanup := CreateRunnerNetwork(t, ctx, &RunnerNetworkConfig{ - Cfg: cfg, - Name: QueryRunner, - Env: map[string]string{ - "QUERY_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "/here/there/every/where", - }, - }) - - assert.NotNil(t, conn) - assert.NotNil(t, cleanup) - - cleanup() -} - -func TestCreateServiceNetwork(t *testing.T) { - if testing.Short() { - t.Skip("Skipping long test in short mode") - } - ctx := context.Background() - - conn, cleanup := CreateServiceNetwork(t, ctx, &ServiceNetworkConfig{ - Name: QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "/here/there/every/where", - }, - }) - - assert.NotNil(t, conn) - assert.NotNil(t, cleanup) - - cleanup() -} - -func TestCreateRunnersAndServicesNetwork(t *testing.T) { - if testing.Short() { - t.Skip("Skipping long test in short mode") - } - ctx := context.Background() - cfg := &serviceconfig.BaseConfig{} - SetCfgProviderWithBasePath(t, cfg, "../..") - - conn, cleanup := CreateRunnersAndServicesNetwork(t, ctx, &EcosystemNetworkConfig{ - Cfg: cfg, - Runners: []*RunnerNetworkConfig{ - { - Name: QueryRunner, - Env: map[string]string{ - "QUERY_URL": "/i/am/here", - }, - }, - }, - Services: []*ServiceNetworkConfig{ - { - Name: QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "/here/there/every/where", - }, - }, - }, + conn, cleanup := CreateAPINetwork(t, ctx, &ServiceNetworkConfig{ + API: QueryAPI, }) assert.NotNil(t, conn) diff --git a/internal/test/objectstore.go b/internal/test/objectstore.go index 07ef56dc..db4ceb68 100644 --- a/internal/test/objectstore.go +++ b/internal/test/objectstore.go @@ -25,8 +25,10 @@ func CreateBucket(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvi require.NoError(t, err) } +const BucketName = "documentbucket" + func SetBucketNotifs(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, name string) { - arn := fmt.Sprintf("arn:aws:sqs:%s:000000000000:%s", cfg.GetAWSRegion(), DocInitRunner) + arn := GetQueueArn(cfg, DocInitRunnerName) _, err := cfg.GetStoreClient().PutBucketNotificationConfiguration(ctx, &s3.PutBucketNotificationConfigurationInput{ Bucket: &name, NotificationConfiguration: &awstypes.NotificationConfiguration{ @@ -51,7 +53,7 @@ func SetStoreClient(t testing.TB, ctx context.Context, cfg objectstore.ConfigPro require.NoError(t, err) } -func PutObject(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, clientId types.UUID, bucket string, filename string, file io.Reader) string { +func PutObject(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, clientId types.UUID, bucket string, filename string, file io.Reader) { location := fmt.Sprintf("%s/%s", clientId, filename) _, err := cfg.GetStoreClient().PutObject(ctx, &s3.PutObjectInput{ Bucket: &bucket, @@ -59,6 +61,4 @@ func PutObject(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider Body: file, }) require.NoError(t, err) - - return location } diff --git a/internal/test/objectstore_test.go b/internal/test/objectstore_test.go index 55a41bdc..410fb709 100644 --- a/internal/test/objectstore_test.go +++ b/internal/test/objectstore_test.go @@ -82,6 +82,5 @@ func TestPutObject(t *testing.T) { ). Return(&s3.PutObjectOutput{}, nil) - location := PutObject(t, ctx, cfg, clientId, bucketName, filename, file) - assert.Equal(t, expectedLocation, location) + PutObject(t, ctx, cfg, clientId, bucketName, filename, file) } diff --git a/internal/test/queryAPI/service.go b/internal/test/queryAPI/service.go new file mode 100644 index 00000000..c7c3dffc --- /dev/null +++ b/internal/test/queryAPI/service.go @@ -0,0 +1,59 @@ +package queryapitest + +import ( + "context" + "fmt" + "testing" + "time" + + queryapi "queryorchestration/pkg/queryAPI" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func CreateClientWithSync(t testing.TB, ctx context.Context, client queryapi.ClientWithResponsesInterface) *queryapi.DocClient { + t.Helper() + + clientCreateRes, err := client.CreateClientWithResponse(ctx, queryapi.ClientCreate{ + Name: "example_name", + Id: "ID", + }) + require.NoError(t, err) + + canSync := true + _, err = client.UpdateClientWithResponse(ctx, clientCreateRes.JSON201.Id, queryapi.ClientUpdate{ + CanSync: &canSync, + }) + require.NoError(t, err) + + clientRes, err := client.GetClientWithResponse(ctx, clientCreateRes.JSON201.Id) + require.NoError(t, err) + + return clientRes.JSON200 +} + +func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.ClientWithResponsesInterface, id string, status queryapi.ClientStatus) { + t.Helper() + + timeout := time.After(30 * time.Second) + ticker := time.NewTicker(500 * time.Millisecond) + defer ticker.Stop() + + for { + select { + case <-timeout: + require.NoError(t, fmt.Errorf("Timeout waiting for client status to become %s", status)) + case <-ticker.C: + jRes, err := service.GetStatusByClientIdWithResponse(ctx, id) + if err != nil { + assert.NoError(t, err) + } + + if jRes.JSON200.Status == status { + assert.Equal(t, status, jRes.JSON200.Status) + return + } + } + } +} diff --git a/internal/test/queryAPI/service_test.go b/internal/test/queryAPI/service_test.go new file mode 100644 index 00000000..f5c65588 --- /dev/null +++ b/internal/test/queryAPI/service_test.go @@ -0,0 +1,80 @@ +package queryapitest_test + +import ( + "context" + "testing" + + queryapitest "queryorchestration/internal/test/queryAPI" + queryapimock "queryorchestration/mocks/queryapi" + queryapi "queryorchestration/pkg/queryAPI" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" +) + +func TestCreateClientWithSync(t *testing.T) { + ctx := context.Background() + + svcClient := queryapimock.NewMockClientWithResponsesInterface(t) + + svcClient.EXPECT().CreateClientWithResponse( + mock.Anything, + mock.MatchedBy(func(create queryapi.ClientCreate) bool { + return create.Name == "example_name" && create.Id == "ID" + }), + mock.Anything, + ).Return(&queryapi.CreateClientResponse{ + JSON201: &queryapi.ClientIDBody{ + Id: "ID", + }, + }, nil) + + svcClient.EXPECT().UpdateClientWithResponse( + mock.Anything, + mock.MatchedBy(func(id string) bool { + return id == "ID" + }), + mock.MatchedBy(func(create queryapi.ClientUpdate) bool { + return *create.CanSync == true + }), + mock.Anything, + ).Return(&queryapi.UpdateClientResponse{}, nil) + + svcClient.EXPECT().GetClientWithResponse( + mock.Anything, + mock.MatchedBy(func(id string) bool { + return id == "ID" + }), + mock.Anything, + ).Return(&queryapi.GetClientResponse{ + JSON200: &queryapi.DocClient{ + Id: "ID", + }, + }, nil) + + client := queryapitest.CreateClientWithSync(t, ctx, svcClient) + + assert.NotNil(t, client) + assert.NotNil(t, client) + assert.EqualExportedValues(t, queryapi.DocClient{ + Id: "ID", + }, *client) +} + +func TestWaitForClientStatus(t *testing.T) { + ctx := context.Background() + client := queryapimock.NewMockClientWithResponsesInterface(t) + + client.EXPECT().GetStatusByClientIdWithResponse( + mock.Anything, + mock.MatchedBy(func(id string) bool { + return id == "id" + }), + ).Return(&queryapi.GetStatusByClientIdResponse{ + JSON200: &queryapi.ClientStatusBody{ + Status: queryapi.INSYNC, + }, + }, nil) + + queryapitest.WaitForClientStatus(t, ctx, client, "id", queryapi.INSYNC) +} diff --git a/internal/test/queryService/service.go b/internal/test/queryService/service.go deleted file mode 100644 index 7d6ab2f4..00000000 --- a/internal/test/queryService/service.go +++ /dev/null @@ -1,29 +0,0 @@ -package queryservicetest - -import ( - "context" - "testing" - - queryservice "queryorchestration/pkg/queryService" - - "github.com/stretchr/testify/require" -) - -func CreateClientWithSync(t testing.TB, ctx context.Context, client queryservice.ClientWithResponsesInterface) *queryservice.DocClient { - clientCreateRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ - Name: "example_name", - Id: "ID", - }) - require.NoError(t, err) - - canSync := true - _, err = client.UpdateClientWithResponse(ctx, clientCreateRes.JSON201.Id, queryservice.ClientUpdate{ - CanSync: &canSync, - }) - require.NoError(t, err) - - clientRes, err := client.GetClientWithResponse(ctx, clientCreateRes.JSON201.Id) - require.NoError(t, err) - - return clientRes.JSON200 -} diff --git a/internal/test/queryService/service_test.go b/internal/test/queryService/service_test.go deleted file mode 100644 index ecde52c7..00000000 --- a/internal/test/queryService/service_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package queryservicetest_test - -import ( - "context" - "testing" - - queryservicetest "queryorchestration/internal/test/queryService" - queryservicemock "queryorchestration/mocks/queryservice" - queryservice "queryorchestration/pkg/queryService" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" -) - -func TestCreateClientWithSync(t *testing.T) { - ctx := context.Background() - - svcClient := queryservicemock.NewMockClientWithResponsesInterface(t) - - svcClient.EXPECT().CreateClientWithResponse( - mock.Anything, - mock.MatchedBy(func(create queryservice.ClientCreate) bool { - return create.Name == "example_name" && create.Id == "ID" - }), - mock.Anything, - ).Return(&queryservice.CreateClientResponse{ - JSON201: &queryservice.ClientIDBody{ - Id: "ID", - }, - }, nil) - - svcClient.EXPECT().UpdateClientWithResponse( - mock.Anything, - mock.MatchedBy(func(id string) bool { - return id == "ID" - }), - mock.MatchedBy(func(create queryservice.ClientUpdate) bool { - return *create.CanSync == true - }), - mock.Anything, - ).Return(&queryservice.UpdateClientResponse{}, nil) - - svcClient.EXPECT().GetClientWithResponse( - mock.Anything, - mock.MatchedBy(func(id string) bool { - return id == "ID" - }), - mock.Anything, - ).Return(&queryservice.GetClientResponse{ - JSON200: &queryservice.DocClient{ - Id: "ID", - }, - }, nil) - - client := queryservicetest.CreateClientWithSync(t, ctx, svcClient) - - assert.NotNil(t, client) - assert.NotNil(t, client) - assert.EqualExportedValues(t, queryservice.DocClient{ - Id: "ID", - }, *client) -} diff --git a/internal/test/queue.go b/internal/test/queue.go index 091489e3..c1f2139b 100644 --- a/internal/test/queue.go +++ b/internal/test/queue.go @@ -2,12 +2,15 @@ package test import ( "context" + "fmt" "regexp" "testing" "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/queue" + awsc "queryorchestration/internal/serviceconfig/aws" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sqs" "github.com/aws/aws-sdk-go-v2/service/sqs/types" @@ -20,6 +23,14 @@ func SetQueueClient(t testing.TB, ctx context.Context, cfg queue.ConfigProvider) require.NoError(t, err) } +func GetQueueURL(cfg awsc.ConfigProvider, name RunnerName) string { + return fmt.Sprintf("http://localstack:4566/queue/%s/000000000000/%s", cfg.GetAWSRegion(), name) +} + +func GetQueueArn(cfg awsc.ConfigProvider, name RunnerName) string { + return fmt.Sprintf("arn:aws:sqs:%s:000000000000:%s", cfg.GetAWSRegion(), name) +} + func CreateQueue(t testing.TB, ctx context.Context, cfg serviceconfig.ConfigProvider, name string) string { queueM, err := cfg.GetQueueClient().CreateQueue(ctx, &sqs.CreateQueueInput{ QueueName: aws.String(name), diff --git a/internal/test/queue_test.go b/internal/test/queue_test.go index 9abfef33..3fd7e631 100644 --- a/internal/test/queue_test.go +++ b/internal/test/queue_test.go @@ -8,6 +8,8 @@ import ( "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/queue" + awsc "queryorchestration/internal/serviceconfig/aws" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sqs/types" "github.com/stretchr/testify/assert" @@ -123,3 +125,17 @@ func TestAssertMessageAttrWait(t *testing.T) { AssertMessageAttr(t, ctx, cfg, url, name, regexp.MustCompile(value)) } + +func TestGetQueueURL(t *testing.T) { + cfg := &awsc.AWSConfig{ + AWSRegion: "us-east-1", + } + assert.Equal(t, "http://localstack:4566/queue/us-east-1/000000000000/docInitRunner", GetQueueURL(cfg, DocInitRunnerName)) +} + +func TestGetQueueARN(t *testing.T) { + cfg := &awsc.AWSConfig{ + AWSRegion: "us-east-1", + } + assert.Equal(t, "arn:aws:sqs:us-east-1:000000000000:docInitRunner", GetQueueArn(cfg, DocInitRunnerName)) +} diff --git a/internal/test/runner.go b/internal/test/runner.go index 24efbdd1..b5a7e18d 100644 --- a/internal/test/runner.go +++ b/internal/test/runner.go @@ -14,47 +14,135 @@ import ( queryversionsyncrunner "queryorchestration/api/queryVersionSyncRunner" "queryorchestration/internal/serviceconfig" + "queryorchestration/internal/serviceconfig/queue/clientsync" + "queryorchestration/internal/serviceconfig/queue/documentclean" + "queryorchestration/internal/serviceconfig/queue/documentinit" + "queryorchestration/internal/serviceconfig/queue/documentsync" + "queryorchestration/internal/serviceconfig/queue/documenttext" + "queryorchestration/internal/serviceconfig/queue/query" + "queryorchestration/internal/serviceconfig/queue/querysync" + "queryorchestration/internal/serviceconfig/queue/queryversionsync" "github.com/testcontainers/testcontainers-go" ) -type Runner = string +type RunnerName = string const ( - DocInitRunner = docinitrunner.Name - DocSyncRunner = docsyncrunner.Name - DocCleanRunner = doccleanrunner.Name - DocTextRunner = doctextrunner.Name - QuerySyncRunner = querysyncrunner.Name - QueryRunner = queryrunner.Name - ClientSyncRunner = clientsyncrunner.Name - QueryVersionSyncRunner = queryversionsyncrunner.Name + DocInitRunnerName RunnerName = docinitrunner.Name + DocSyncRunnerName RunnerName = docsyncrunner.Name + DocCleanRunnerName RunnerName = doccleanrunner.Name + DocTextRunnerName RunnerName = doctextrunner.Name + QuerySyncRunnerName RunnerName = querysyncrunner.Name + QueryRunnerName RunnerName = queryrunner.Name + ClientSyncRunnerName RunnerName = clientsyncrunner.Name + QueryVersionSyncRunnerName RunnerName = queryversionsyncrunner.Name ) +type RunnerEnv = string + +const ( + DocInitRunnerEnv RunnerEnv = documentinit.EnvName + DocSyncRunnerEnv RunnerEnv = documentsync.EnvName + DocCleanRunnerEnv RunnerEnv = documentclean.EnvName + DocTextRunnerEnv RunnerEnv = documenttext.EnvName + QuerySyncRunnerEnv RunnerEnv = querysync.EnvName + QueryRunnerEnv RunnerEnv = query.EnvName + ClientSyncRunnerEnv RunnerEnv = clientsync.EnvName + QueryVersionSyncRunnerEnv RunnerEnv = queryversionsync.EnvName +) + +type Runner struct { + Name RunnerName + DownstreamQueues []RunnerName +} + +func GetRunnerEnvFromName(name RunnerName) RunnerEnv { + switch name { + case DocSyncRunnerName: + return DocSyncRunnerEnv + case DocCleanRunnerName: + return DocCleanRunnerEnv + case DocTextRunnerName: + return DocTextRunnerEnv + case QuerySyncRunnerName: + return QuerySyncRunnerEnv + case QueryRunnerName: + return QueryRunnerEnv + case ClientSyncRunnerName: + return ClientSyncRunnerEnv + case QueryVersionSyncRunnerName: + return QueryVersionSyncRunnerEnv + } + return DocInitRunnerEnv +} + type RunnerConfig struct { - Name Runner - QueueURL string - Cfg serviceconfig.ConfigProvider - Network *testcontainers.DockerNetwork - Env map[string]string + Runner Runner + Cfg serviceconfig.ConfigProvider + Network *testcontainers.DockerNetwork } func CreateRunner(t testing.TB, ctx context.Context, config *RunnerConfig) (*Container, func()) { - if config.Env == nil { - config.Env = map[string]string{} - } - config.Env["QUEUE_URL"] = config.QueueURL + env := map[string]string{} + url := GetQueueURL(config.Cfg, config.Runner.Name) + env["QUEUE_URL"] = url c, cleanup := createContainer(t, ctx, &containerConfig{ - Network: config.Network, - Name: config.Name, - Cfg: config.Cfg, - Env: config.Env, - WaitForMsg: "Listening to queue", + Network: config.Network, + Name: config.Runner.Name, + DownstreamQueues: config.Runner.DownstreamQueues, + Cfg: config.Cfg, + Env: env, + WaitForMsg: "Listening to queue", }) return &Container{ Container: c, - URI: config.QueueURL, + URI: url, }, cleanup } + +var DocInitRunner = Runner{ + Name: DocInitRunnerName, + DownstreamQueues: []RunnerName{DocSyncRunnerName}, +} +var DocSyncRunner = Runner{ + Name: DocSyncRunnerName, + DownstreamQueues: []RunnerName{DocCleanRunnerName}, +} +var DocCleanRunner = Runner{ + Name: DocCleanRunnerName, + DownstreamQueues: []RunnerName{DocTextRunnerName}, +} +var DocTextRunner = Runner{ + Name: DocTextRunnerName, + DownstreamQueues: []RunnerName{QuerySyncRunnerName}, +} +var QuerySyncRunner = Runner{ + Name: QuerySyncRunnerName, + DownstreamQueues: []RunnerName{QueryRunnerName}, +} +var QueryRunner = Runner{ + Name: QueryRunnerName, + DownstreamQueues: []RunnerName{QueryRunnerName}, +} +var ClientSyncRunner = Runner{ + Name: ClientSyncRunnerName, + DownstreamQueues: []RunnerName{DocSyncRunnerName}, +} +var QueryVersionSyncRunner = Runner{ + Name: QueryVersionSyncRunnerName, + DownstreamQueues: []RunnerName{ClientSyncRunnerName}, +} + +var runners = []Runner{ + DocInitRunner, + DocSyncRunner, + DocCleanRunner, + DocTextRunner, + QuerySyncRunner, + QueryRunner, + ClientSyncRunner, + QueryVersionSyncRunner, +} diff --git a/internal/test/runner_test.go b/internal/test/runner_test.go index 925839b4..c15310be 100644 --- a/internal/test/runner_test.go +++ b/internal/test/runner_test.go @@ -28,7 +28,7 @@ func TestCreateRunner(t *testing.T) { defer qcleanup() err := cfg.SetQueueClient(ctx) assert.NoError(t, err) - url := CreateQueue(t, ctx, cfg, "myname") + _ = CreateQueue(t, ctx, cfg, QueryRunnerName) _, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{ Network: ncfg, @@ -37,13 +37,9 @@ func TestCreateRunner(t *testing.T) { defer dbcleanup() qccfg := &RunnerConfig{ - Name: QueryRunner, - Cfg: cfg, - Network: ncfg, - QueueURL: url, - Env: map[string]string{ - "QUERY_URL": "/i/am/here", - }, + Runner: QueryRunner, + Cfg: cfg, + Network: ncfg, } c, cleanup := CreateRunner(t, ctx, qccfg) @@ -52,3 +48,15 @@ func TestCreateRunner(t *testing.T) { cleanup() } + +func TestGetRunnerEnvFromName(t *testing.T) { + assert.Equal(t, DocInitRunnerEnv, GetRunnerEnvFromName(DocInitRunnerName)) + assert.Equal(t, DocSyncRunnerEnv, GetRunnerEnvFromName(DocSyncRunnerName)) + assert.Equal(t, DocCleanRunnerEnv, GetRunnerEnvFromName(DocCleanRunnerName)) + assert.Equal(t, DocTextRunnerEnv, GetRunnerEnvFromName(DocTextRunnerName)) + assert.Equal(t, QuerySyncRunnerEnv, GetRunnerEnvFromName(QuerySyncRunnerName)) + assert.Equal(t, QueryRunnerEnv, GetRunnerEnvFromName(QueryRunnerName)) + assert.Equal(t, ClientSyncRunnerEnv, GetRunnerEnvFromName(ClientSyncRunnerName)) + assert.Equal(t, QueryVersionSyncRunnerEnv, GetRunnerEnvFromName(QueryVersionSyncRunnerName)) + assert.Equal(t, DocInitRunnerEnv, GetRunnerEnvFromName(DocInitRunnerName)) +} diff --git a/mocks/queryservice/mock_ClientInterface.go b/mocks/queryapi/mock_ClientInterface.go similarity index 71% rename from mocks/queryservice/mock_ClientInterface.go rename to mocks/queryapi/mock_ClientInterface.go index 8430a69d..57a4d549 100644 --- a/mocks/queryservice/mock_ClientInterface.go +++ b/mocks/queryapi/mock_ClientInterface.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.52.3. DO NOT EDIT. -package queryservicemock +package queryapimock import ( context "context" @@ -10,7 +10,7 @@ import ( mock "github.com/stretchr/testify/mock" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" uuid "github.com/google/uuid" ) @@ -29,7 +29,7 @@ func (_m *MockClientInterface) EXPECT() *MockClientInterface_Expecter { } // CreateClient provides a mock function with given fields: ctx, body, reqEditors -func (_m *MockClientInterface) CreateClient(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) CreateClient(ctx context.Context, body queryapi.ClientCreate, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -45,10 +45,10 @@ func (_m *MockClientInterface) CreateClient(ctx context.Context, body queryservi var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -56,7 +56,7 @@ func (_m *MockClientInterface) CreateClient(ctx context.Context, body queryservi } } - if rf, ok := ret.Get(1).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, body, reqEditors...) } else { r1 = ret.Error(1) @@ -72,22 +72,22 @@ type MockClientInterface_CreateClient_Call struct { // CreateClient is a helper method to define mock.On call // - ctx context.Context -// - body queryservice.ClientCreate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ClientCreate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) CreateClient(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateClient_Call { return &MockClientInterface_CreateClient_Call{Call: _e.mock.On("CreateClient", append([]interface{}{ctx, body}, reqEditors...)...)} } -func (_c *MockClientInterface_CreateClient_Call) Run(run func(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateClient_Call { +func (_c *MockClientInterface_CreateClient_Call) Run(run func(ctx context.Context, body queryapi.ClientCreate, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_CreateClient_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(queryservice.ClientCreate), variadicArgs...) + run(args[0].(context.Context), args[1].(queryapi.ClientCreate), variadicArgs...) }) return _c } @@ -97,13 +97,13 @@ func (_c *MockClientInterface_CreateClient_Call) Return(_a0 *http.Response, _a1 return _c } -func (_c *MockClientInterface_CreateClient_Call) RunAndReturn(run func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClient_Call { +func (_c *MockClientInterface_CreateClient_Call) RunAndReturn(run func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClient_Call { _c.Call.Return(run) return _c } // CreateClientWithBody provides a mock function with given fields: ctx, contentType, body, reqEditors -func (_m *MockClientInterface) CreateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) CreateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -119,10 +119,10 @@ func (_m *MockClientInterface) CreateClientWithBody(ctx context.Context, content var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -130,7 +130,7 @@ func (_m *MockClientInterface) CreateClientWithBody(ctx context.Context, content } } - if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -148,18 +148,18 @@ type MockClientInterface_CreateClientWithBody_Call struct { // - ctx context.Context // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) CreateClientWithBody(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateClientWithBody_Call { return &MockClientInterface_CreateClientWithBody_Call{Call: _e.mock.On("CreateClientWithBody", append([]interface{}{ctx, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_CreateClientWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateClientWithBody_Call { +func (_c *MockClientInterface_CreateClientWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_CreateClientWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) @@ -172,13 +172,13 @@ func (_c *MockClientInterface_CreateClientWithBody_Call) Return(_a0 *http.Respon return _c } -func (_c *MockClientInterface_CreateClientWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClientWithBody_Call { +func (_c *MockClientInterface_CreateClientWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClientWithBody_Call { _c.Call.Return(run) return _c } // CreateQuery provides a mock function with given fields: ctx, body, reqEditors -func (_m *MockClientInterface) CreateQuery(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) CreateQuery(ctx context.Context, body queryapi.QueryCreate, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -194,10 +194,10 @@ func (_m *MockClientInterface) CreateQuery(ctx context.Context, body queryservic var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -205,7 +205,7 @@ func (_m *MockClientInterface) CreateQuery(ctx context.Context, body queryservic } } - if rf, ok := ret.Get(1).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, body, reqEditors...) } else { r1 = ret.Error(1) @@ -221,22 +221,22 @@ type MockClientInterface_CreateQuery_Call struct { // CreateQuery is a helper method to define mock.On call // - ctx context.Context -// - body queryservice.QueryCreate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryCreate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) CreateQuery(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateQuery_Call { return &MockClientInterface_CreateQuery_Call{Call: _e.mock.On("CreateQuery", append([]interface{}{ctx, body}, reqEditors...)...)} } -func (_c *MockClientInterface_CreateQuery_Call) Run(run func(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateQuery_Call { +func (_c *MockClientInterface_CreateQuery_Call) Run(run func(ctx context.Context, body queryapi.QueryCreate, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_CreateQuery_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(queryservice.QueryCreate), variadicArgs...) + run(args[0].(context.Context), args[1].(queryapi.QueryCreate), variadicArgs...) }) return _c } @@ -246,13 +246,13 @@ func (_c *MockClientInterface_CreateQuery_Call) Return(_a0 *http.Response, _a1 e return _c } -func (_c *MockClientInterface_CreateQuery_Call) RunAndReturn(run func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQuery_Call { +func (_c *MockClientInterface_CreateQuery_Call) RunAndReturn(run func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQuery_Call { _c.Call.Return(run) return _c } // CreateQueryWithBody provides a mock function with given fields: ctx, contentType, body, reqEditors -func (_m *MockClientInterface) CreateQueryWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) CreateQueryWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -268,10 +268,10 @@ func (_m *MockClientInterface) CreateQueryWithBody(ctx context.Context, contentT var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -279,7 +279,7 @@ func (_m *MockClientInterface) CreateQueryWithBody(ctx context.Context, contentT } } - if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -297,18 +297,18 @@ type MockClientInterface_CreateQueryWithBody_Call struct { // - ctx context.Context // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) CreateQueryWithBody(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateQueryWithBody_Call { return &MockClientInterface_CreateQueryWithBody_Call{Call: _e.mock.On("CreateQueryWithBody", append([]interface{}{ctx, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_CreateQueryWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateQueryWithBody_Call { +func (_c *MockClientInterface_CreateQueryWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_CreateQueryWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) @@ -321,13 +321,13 @@ func (_c *MockClientInterface_CreateQueryWithBody_Call) Return(_a0 *http.Respons return _c } -func (_c *MockClientInterface_CreateQueryWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQueryWithBody_Call { +func (_c *MockClientInterface_CreateQueryWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQueryWithBody_Call { _c.Call.Return(run) return _c } // ExportState provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) ExportState(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) ExportState(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -343,10 +343,10 @@ func (_m *MockClientInterface) ExportState(ctx context.Context, id uuid.UUID, re var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -354,7 +354,7 @@ func (_m *MockClientInterface) ExportState(ctx context.Context, id uuid.UUID, re } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -371,18 +371,18 @@ type MockClientInterface_ExportState_Call struct { // ExportState is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) ExportState(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_ExportState_Call { return &MockClientInterface_ExportState_Call{Call: _e.mock.On("ExportState", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_ExportState_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ExportState_Call { +func (_c *MockClientInterface_ExportState_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_ExportState_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) @@ -395,13 +395,13 @@ func (_c *MockClientInterface_ExportState_Call) Return(_a0 *http.Response, _a1 e return _c } -func (_c *MockClientInterface_ExportState_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ExportState_Call { +func (_c *MockClientInterface_ExportState_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ExportState_Call { _c.Call.Return(run) return _c } // GetClient provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) GetClient(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) GetClient(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -417,10 +417,10 @@ func (_m *MockClientInterface) GetClient(ctx context.Context, id string, reqEdit var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -428,7 +428,7 @@ func (_m *MockClientInterface) GetClient(ctx context.Context, id string, reqEdit } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -445,18 +445,18 @@ type MockClientInterface_GetClient_Call struct { // GetClient is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) GetClient(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetClient_Call { return &MockClientInterface_GetClient_Call{Call: _e.mock.On("GetClient", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_GetClient_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetClient_Call { +func (_c *MockClientInterface_GetClient_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_GetClient_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -469,13 +469,13 @@ func (_c *MockClientInterface_GetClient_Call) Return(_a0 *http.Response, _a1 err return _c } -func (_c *MockClientInterface_GetClient_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetClient_Call { +func (_c *MockClientInterface_GetClient_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetClient_Call { _c.Call.Return(run) return _c } // GetCollectorByClientId provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) GetCollectorByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) GetCollectorByClientId(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -491,10 +491,10 @@ func (_m *MockClientInterface) GetCollectorByClientId(ctx context.Context, id st var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -502,7 +502,7 @@ func (_m *MockClientInterface) GetCollectorByClientId(ctx context.Context, id st } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -519,18 +519,18 @@ type MockClientInterface_GetCollectorByClientId_Call struct { // GetCollectorByClientId is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) GetCollectorByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetCollectorByClientId_Call { return &MockClientInterface_GetCollectorByClientId_Call{Call: _e.mock.On("GetCollectorByClientId", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_GetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetCollectorByClientId_Call { +func (_c *MockClientInterface_GetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_GetCollectorByClientId_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -543,13 +543,87 @@ func (_c *MockClientInterface_GetCollectorByClientId_Call) Return(_a0 *http.Resp return _c } -func (_c *MockClientInterface_GetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetCollectorByClientId_Call { +func (_c *MockClientInterface_GetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetCollectorByClientId_Call { + _c.Call.Return(run) + return _c +} + +// GetDocument provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) GetDocument(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetDocument") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_GetDocument_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDocument' +type MockClientInterface_GetDocument_Call struct { + *mock.Call +} + +// GetDocument is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryapi.RequestEditorFn +func (_e *MockClientInterface_Expecter) GetDocument(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetDocument_Call { + return &MockClientInterface_GetDocument_Call{Call: _e.mock.On("GetDocument", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_GetDocument_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_GetDocument_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryapi.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_GetDocument_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_GetDocument_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_GetDocument_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetDocument_Call { _c.Call.Return(run) return _c } // GetQuery provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) GetQuery(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) GetQuery(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -565,10 +639,10 @@ func (_m *MockClientInterface) GetQuery(ctx context.Context, id uuid.UUID, reqEd var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -576,7 +650,7 @@ func (_m *MockClientInterface) GetQuery(ctx context.Context, id uuid.UUID, reqEd } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -593,18 +667,18 @@ type MockClientInterface_GetQuery_Call struct { // GetQuery is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) GetQuery(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetQuery_Call { return &MockClientInterface_GetQuery_Call{Call: _e.mock.On("GetQuery", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_GetQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetQuery_Call { +func (_c *MockClientInterface_GetQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_GetQuery_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) @@ -617,13 +691,13 @@ func (_c *MockClientInterface_GetQuery_Call) Return(_a0 *http.Response, _a1 erro return _c } -func (_c *MockClientInterface_GetQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetQuery_Call { +func (_c *MockClientInterface_GetQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetQuery_Call { _c.Call.Return(run) return _c } // GetStatusByClientId provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) GetStatusByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) GetStatusByClientId(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -639,10 +713,10 @@ func (_m *MockClientInterface) GetStatusByClientId(ctx context.Context, id strin var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -650,7 +724,7 @@ func (_m *MockClientInterface) GetStatusByClientId(ctx context.Context, id strin } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -667,18 +741,18 @@ type MockClientInterface_GetStatusByClientId_Call struct { // GetStatusByClientId is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) GetStatusByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetStatusByClientId_Call { return &MockClientInterface_GetStatusByClientId_Call{Call: _e.mock.On("GetStatusByClientId", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_GetStatusByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetStatusByClientId_Call { +func (_c *MockClientInterface_GetStatusByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_GetStatusByClientId_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -691,13 +765,13 @@ func (_c *MockClientInterface_GetStatusByClientId_Call) Return(_a0 *http.Respons return _c } -func (_c *MockClientInterface_GetStatusByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetStatusByClientId_Call { +func (_c *MockClientInterface_GetStatusByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetStatusByClientId_Call { _c.Call.Return(run) return _c } // ListDocumentsByClientId provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -713,10 +787,10 @@ func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id s var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { @@ -724,7 +798,7 @@ func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id s } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -741,18 +815,18 @@ type MockClientInterface_ListDocumentsByClientId_Call struct { // ListDocumentsByClientId is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) ListDocumentsByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_ListDocumentsByClientId_Call { return &MockClientInterface_ListDocumentsByClientId_Call{Call: _e.mock.On("ListDocumentsByClientId", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientInterface_ListDocumentsByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ListDocumentsByClientId_Call { +func (_c *MockClientInterface_ListDocumentsByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_ListDocumentsByClientId_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -765,13 +839,13 @@ func (_c *MockClientInterface_ListDocumentsByClientId_Call) Return(_a0 *http.Res return _c } -func (_c *MockClientInterface_ListDocumentsByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListDocumentsByClientId_Call { +func (_c *MockClientInterface_ListDocumentsByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListDocumentsByClientId_Call { _c.Call.Return(run) return _c } // ListQueries provides a mock function with given fields: ctx, reqEditors -func (_m *MockClientInterface) ListQueries(ctx context.Context, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) ListQueries(ctx context.Context, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -787,10 +861,10 @@ func (_m *MockClientInterface) ListQueries(ctx context.Context, reqEditors ...qu var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, reqEditors...) } else { if ret.Get(0) != nil { @@ -798,7 +872,7 @@ func (_m *MockClientInterface) ListQueries(ctx context.Context, reqEditors ...qu } } - if rf, ok := ret.Get(1).(func(context.Context, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, reqEditors...) } else { r1 = ret.Error(1) @@ -814,18 +888,18 @@ type MockClientInterface_ListQueries_Call struct { // ListQueries is a helper method to define mock.On call // - ctx context.Context -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) ListQueries(ctx interface{}, reqEditors ...interface{}) *MockClientInterface_ListQueries_Call { return &MockClientInterface_ListQueries_Call{Call: _e.mock.On("ListQueries", append([]interface{}{ctx}, reqEditors...)...)} } -func (_c *MockClientInterface_ListQueries_Call) Run(run func(ctx context.Context, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ListQueries_Call { +func (_c *MockClientInterface_ListQueries_Call) Run(run func(ctx context.Context, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_ListQueries_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-1) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-1) for i, a := range args[1:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), variadicArgs...) @@ -838,13 +912,13 @@ func (_c *MockClientInterface_ListQueries_Call) Return(_a0 *http.Response, _a1 e return _c } -func (_c *MockClientInterface_ListQueries_Call) RunAndReturn(run func(context.Context, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListQueries_Call { +func (_c *MockClientInterface_ListQueries_Call) RunAndReturn(run func(context.Context, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListQueries_Call { _c.Call.Return(run) return _c } // SetCollectorByClientId provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientInterface) SetCollectorByClientId(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) SetCollectorByClientId(ctx context.Context, id string, body queryapi.CollectorSet, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -860,10 +934,10 @@ func (_m *MockClientInterface) SetCollectorByClientId(ctx context.Context, id st var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -871,7 +945,7 @@ func (_m *MockClientInterface) SetCollectorByClientId(ctx context.Context, id st } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -888,22 +962,22 @@ type MockClientInterface_SetCollectorByClientId_Call struct { // SetCollectorByClientId is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.CollectorSet -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.CollectorSet +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) SetCollectorByClientId(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_SetCollectorByClientId_Call { return &MockClientInterface_SetCollectorByClientId_Call{Call: _e.mock.On("SetCollectorByClientId", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientInterface_SetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_SetCollectorByClientId_Call { +func (_c *MockClientInterface_SetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, body queryapi.CollectorSet, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_SetCollectorByClientId_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.CollectorSet), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.CollectorSet), variadicArgs...) }) return _c } @@ -913,13 +987,13 @@ func (_c *MockClientInterface_SetCollectorByClientId_Call) Return(_a0 *http.Resp return _c } -func (_c *MockClientInterface_SetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientId_Call { +func (_c *MockClientInterface_SetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientId_Call { _c.Call.Return(run) return _c } // SetCollectorByClientIdWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientInterface) SetCollectorByClientIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) SetCollectorByClientIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -935,10 +1009,10 @@ func (_m *MockClientInterface) SetCollectorByClientIdWithBody(ctx context.Contex var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -946,7 +1020,7 @@ func (_m *MockClientInterface) SetCollectorByClientIdWithBody(ctx context.Contex } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -965,18 +1039,18 @@ type MockClientInterface_SetCollectorByClientIdWithBody_Call struct { // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) SetCollectorByClientIdWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_SetCollectorByClientIdWithBody_Call { return &MockClientInterface_SetCollectorByClientIdWithBody_Call{Call: _e.mock.On("SetCollectorByClientIdWithBody", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { +func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -989,13 +1063,13 @@ func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) Return(_a0 *h return _c } -func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { +func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { _c.Call.Return(run) return _c } // TestQuery provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientInterface) TestQuery(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) TestQuery(ctx context.Context, id uuid.UUID, body queryapi.QueryTestRequest, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1011,10 +1085,10 @@ func (_m *MockClientInterface) TestQuery(ctx context.Context, id uuid.UUID, body var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1022,7 +1096,7 @@ func (_m *MockClientInterface) TestQuery(ctx context.Context, id uuid.UUID, body } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1039,22 +1113,22 @@ type MockClientInterface_TestQuery_Call struct { // TestQuery is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - body queryservice.QueryTestRequest -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryTestRequest +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) TestQuery(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TestQuery_Call { return &MockClientInterface_TestQuery_Call{Call: _e.mock.On("TestQuery", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientInterface_TestQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TestQuery_Call { +func (_c *MockClientInterface_TestQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryapi.QueryTestRequest, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_TestQuery_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryTestRequest), variadicArgs...) + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryapi.QueryTestRequest), variadicArgs...) }) return _c } @@ -1064,13 +1138,13 @@ func (_c *MockClientInterface_TestQuery_Call) Return(_a0 *http.Response, _a1 err return _c } -func (_c *MockClientInterface_TestQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQuery_Call { +func (_c *MockClientInterface_TestQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQuery_Call { _c.Call.Return(run) return _c } // TestQueryWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientInterface) TestQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) TestQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1086,10 +1160,10 @@ func (_m *MockClientInterface) TestQueryWithBody(ctx context.Context, id uuid.UU var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1097,7 +1171,7 @@ func (_m *MockClientInterface) TestQueryWithBody(ctx context.Context, id uuid.UU } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1116,18 +1190,18 @@ type MockClientInterface_TestQueryWithBody_Call struct { // - id uuid.UUID // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) TestQueryWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TestQueryWithBody_Call { return &MockClientInterface_TestQueryWithBody_Call{Call: _e.mock.On("TestQueryWithBody", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_TestQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TestQueryWithBody_Call { +func (_c *MockClientInterface_TestQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_TestQueryWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1140,13 +1214,13 @@ func (_c *MockClientInterface_TestQueryWithBody_Call) Return(_a0 *http.Response, return _c } -func (_c *MockClientInterface_TestQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQueryWithBody_Call { +func (_c *MockClientInterface_TestQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQueryWithBody_Call { _c.Call.Return(run) return _c } // TriggerExport provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientInterface) TriggerExport(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) TriggerExport(ctx context.Context, id string, body queryapi.ExportTrigger, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1162,10 +1236,10 @@ func (_m *MockClientInterface) TriggerExport(ctx context.Context, id string, bod var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1173,7 +1247,7 @@ func (_m *MockClientInterface) TriggerExport(ctx context.Context, id string, bod } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1190,22 +1264,22 @@ type MockClientInterface_TriggerExport_Call struct { // TriggerExport is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.ExportTrigger -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ExportTrigger +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) TriggerExport(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TriggerExport_Call { return &MockClientInterface_TriggerExport_Call{Call: _e.mock.On("TriggerExport", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientInterface_TriggerExport_Call) Run(run func(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TriggerExport_Call { +func (_c *MockClientInterface_TriggerExport_Call) Run(run func(ctx context.Context, id string, body queryapi.ExportTrigger, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_TriggerExport_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ExportTrigger), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.ExportTrigger), variadicArgs...) }) return _c } @@ -1215,13 +1289,13 @@ func (_c *MockClientInterface_TriggerExport_Call) Return(_a0 *http.Response, _a1 return _c } -func (_c *MockClientInterface_TriggerExport_Call) RunAndReturn(run func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExport_Call { +func (_c *MockClientInterface_TriggerExport_Call) RunAndReturn(run func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExport_Call { _c.Call.Return(run) return _c } // TriggerExportWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientInterface) TriggerExportWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) TriggerExportWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1237,10 +1311,10 @@ func (_m *MockClientInterface) TriggerExportWithBody(ctx context.Context, id str var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1248,7 +1322,7 @@ func (_m *MockClientInterface) TriggerExportWithBody(ctx context.Context, id str } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1267,18 +1341,18 @@ type MockClientInterface_TriggerExportWithBody_Call struct { // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) TriggerExportWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TriggerExportWithBody_Call { return &MockClientInterface_TriggerExportWithBody_Call{Call: _e.mock.On("TriggerExportWithBody", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_TriggerExportWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TriggerExportWithBody_Call { +func (_c *MockClientInterface_TriggerExportWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_TriggerExportWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1291,13 +1365,13 @@ func (_c *MockClientInterface_TriggerExportWithBody_Call) Return(_a0 *http.Respo return _c } -func (_c *MockClientInterface_TriggerExportWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExportWithBody_Call { +func (_c *MockClientInterface_TriggerExportWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExportWithBody_Call { _c.Call.Return(run) return _c } // UpdateClient provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientInterface) UpdateClient(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) UpdateClient(ctx context.Context, id string, body queryapi.ClientUpdate, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1313,10 +1387,10 @@ func (_m *MockClientInterface) UpdateClient(ctx context.Context, id string, body var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1324,7 +1398,7 @@ func (_m *MockClientInterface) UpdateClient(ctx context.Context, id string, body } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1341,22 +1415,22 @@ type MockClientInterface_UpdateClient_Call struct { // UpdateClient is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.ClientUpdate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ClientUpdate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) UpdateClient(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateClient_Call { return &MockClientInterface_UpdateClient_Call{Call: _e.mock.On("UpdateClient", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientInterface_UpdateClient_Call) Run(run func(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateClient_Call { +func (_c *MockClientInterface_UpdateClient_Call) Run(run func(ctx context.Context, id string, body queryapi.ClientUpdate, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_UpdateClient_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ClientUpdate), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.ClientUpdate), variadicArgs...) }) return _c } @@ -1366,13 +1440,13 @@ func (_c *MockClientInterface_UpdateClient_Call) Return(_a0 *http.Response, _a1 return _c } -func (_c *MockClientInterface_UpdateClient_Call) RunAndReturn(run func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClient_Call { +func (_c *MockClientInterface_UpdateClient_Call) RunAndReturn(run func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClient_Call { _c.Call.Return(run) return _c } // UpdateClientWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientInterface) UpdateClientWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) UpdateClientWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1388,10 +1462,10 @@ func (_m *MockClientInterface) UpdateClientWithBody(ctx context.Context, id stri var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1399,7 +1473,7 @@ func (_m *MockClientInterface) UpdateClientWithBody(ctx context.Context, id stri } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1418,18 +1492,18 @@ type MockClientInterface_UpdateClientWithBody_Call struct { // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) UpdateClientWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateClientWithBody_Call { return &MockClientInterface_UpdateClientWithBody_Call{Call: _e.mock.On("UpdateClientWithBody", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_UpdateClientWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateClientWithBody_Call { +func (_c *MockClientInterface_UpdateClientWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_UpdateClientWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1442,13 +1516,13 @@ func (_c *MockClientInterface_UpdateClientWithBody_Call) Return(_a0 *http.Respon return _c } -func (_c *MockClientInterface_UpdateClientWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClientWithBody_Call { +func (_c *MockClientInterface_UpdateClientWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClientWithBody_Call { _c.Call.Return(run) return _c } // UpdateQuery provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientInterface) UpdateQuery(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) UpdateQuery(ctx context.Context, id uuid.UUID, body queryapi.QueryUpdate, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1464,10 +1538,10 @@ func (_m *MockClientInterface) UpdateQuery(ctx context.Context, id uuid.UUID, bo var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1475,7 +1549,7 @@ func (_m *MockClientInterface) UpdateQuery(ctx context.Context, id uuid.UUID, bo } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1492,22 +1566,22 @@ type MockClientInterface_UpdateQuery_Call struct { // UpdateQuery is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - body queryservice.QueryUpdate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryUpdate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) UpdateQuery(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateQuery_Call { return &MockClientInterface_UpdateQuery_Call{Call: _e.mock.On("UpdateQuery", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientInterface_UpdateQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateQuery_Call { +func (_c *MockClientInterface_UpdateQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryapi.QueryUpdate, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_UpdateQuery_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryUpdate), variadicArgs...) + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryapi.QueryUpdate), variadicArgs...) }) return _c } @@ -1517,13 +1591,13 @@ func (_c *MockClientInterface_UpdateQuery_Call) Return(_a0 *http.Response, _a1 e return _c } -func (_c *MockClientInterface_UpdateQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQuery_Call { +func (_c *MockClientInterface_UpdateQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQuery_Call { _c.Call.Return(run) return _c } // UpdateQueryWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientInterface) UpdateQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { +func (_m *MockClientInterface) UpdateQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1539,10 +1613,10 @@ func (_m *MockClientInterface) UpdateQueryWithBody(ctx context.Context, id uuid. var r0 *http.Response var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) *http.Response); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { @@ -1550,7 +1624,7 @@ func (_m *MockClientInterface) UpdateQueryWithBody(ctx context.Context, id uuid. } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1569,18 +1643,18 @@ type MockClientInterface_UpdateQueryWithBody_Call struct { // - id uuid.UUID // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientInterface_Expecter) UpdateQueryWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateQueryWithBody_Call { return &MockClientInterface_UpdateQueryWithBody_Call{Call: _e.mock.On("UpdateQueryWithBody", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientInterface_UpdateQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateQueryWithBody_Call { +func (_c *MockClientInterface_UpdateQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_UpdateQueryWithBody_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1593,7 +1667,7 @@ func (_c *MockClientInterface_UpdateQueryWithBody_Call) Return(_a0 *http.Respons return _c } -func (_c *MockClientInterface_UpdateQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQueryWithBody_Call { +func (_c *MockClientInterface_UpdateQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQueryWithBody_Call { _c.Call.Return(run) return _c } diff --git a/mocks/queryservice/mock_ClientWithResponsesInterface.go b/mocks/queryapi/mock_ClientWithResponsesInterface.go similarity index 65% rename from mocks/queryservice/mock_ClientWithResponsesInterface.go rename to mocks/queryapi/mock_ClientWithResponsesInterface.go index 524ad16e..e602fa27 100644 --- a/mocks/queryservice/mock_ClientWithResponsesInterface.go +++ b/mocks/queryapi/mock_ClientWithResponsesInterface.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.52.3. DO NOT EDIT. -package queryservicemock +package queryapimock import ( context "context" @@ -8,7 +8,7 @@ import ( mock "github.com/stretchr/testify/mock" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" uuid "github.com/google/uuid" ) @@ -27,7 +27,7 @@ func (_m *MockClientWithResponsesInterface) EXPECT() *MockClientWithResponsesInt } // CreateClientWithBodyWithResponse provides a mock function with given fields: ctx, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) CreateClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error) { +func (_m *MockClientWithResponsesInterface) CreateClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -41,20 +41,20 @@ func (_m *MockClientWithResponsesInterface) CreateClientWithBodyWithResponse(ctx panic("no return value specified for CreateClientWithBodyWithResponse") } - var r0 *queryservice.CreateClientResponse + var r0 *queryapi.CreateClientResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error)); ok { return rf(ctx, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.CreateClientResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.CreateClientResponse); ok { r0 = rf(ctx, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.CreateClientResponse) + r0 = ret.Get(0).(*queryapi.CreateClientResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -72,18 +72,18 @@ type MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call stru // - ctx context.Context // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) CreateClientWithBodyWithResponse(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call{Call: _e.mock.On("CreateClientWithBodyWithResponse", append([]interface{}{ctx, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) @@ -91,18 +91,18 @@ func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call return _c } -func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Return(_a0 *queryservice.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Return(_a0 *queryapi.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // CreateClientWithResponse provides a mock function with given fields: ctx, body, reqEditors -func (_m *MockClientWithResponsesInterface) CreateClientWithResponse(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error) { +func (_m *MockClientWithResponsesInterface) CreateClientWithResponse(ctx context.Context, body queryapi.ClientCreate, reqEditors ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -116,20 +116,20 @@ func (_m *MockClientWithResponsesInterface) CreateClientWithResponse(ctx context panic("no return value specified for CreateClientWithResponse") } - var r0 *queryservice.CreateClientResponse + var r0 *queryapi.CreateClientResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error)); ok { return rf(ctx, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) *queryservice.CreateClientResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) *queryapi.CreateClientResponse); ok { r0 = rf(ctx, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.CreateClientResponse) + r0 = ret.Get(0).(*queryapi.CreateClientResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, body, reqEditors...) } else { r1 = ret.Error(1) @@ -145,38 +145,38 @@ type MockClientWithResponsesInterface_CreateClientWithResponse_Call struct { // CreateClientWithResponse is a helper method to define mock.On call // - ctx context.Context -// - body queryservice.ClientCreate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ClientCreate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) CreateClientWithResponse(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { return &MockClientWithResponsesInterface_CreateClientWithResponse_Call{Call: _e.mock.On("CreateClientWithResponse", append([]interface{}{ctx, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Run(run func(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Run(run func(ctx context.Context, body queryapi.ClientCreate, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(queryservice.ClientCreate), variadicArgs...) + run(args[0].(context.Context), args[1].(queryapi.ClientCreate), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Return(_a0 *queryservice.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Return(_a0 *queryapi.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) RunAndReturn(run func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) RunAndReturn(run func(context.Context, queryapi.ClientCreate, ...queryapi.RequestEditorFn) (*queryapi.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { _c.Call.Return(run) return _c } // CreateQueryWithBodyWithResponse provides a mock function with given fields: ctx, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) CreateQueryWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) CreateQueryWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -190,20 +190,20 @@ func (_m *MockClientWithResponsesInterface) CreateQueryWithBodyWithResponse(ctx panic("no return value specified for CreateQueryWithBodyWithResponse") } - var r0 *queryservice.CreateQueryResponse + var r0 *queryapi.CreateQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error)); ok { return rf(ctx, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.CreateQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.CreateQueryResponse); ok { r0 = rf(ctx, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.CreateQueryResponse) + r0 = ret.Get(0).(*queryapi.CreateQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -221,18 +221,18 @@ type MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call struc // - ctx context.Context // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) CreateQueryWithBodyWithResponse(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call{Call: _e.mock.On("CreateQueryWithBodyWithResponse", append([]interface{}{ctx, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) @@ -240,18 +240,18 @@ func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) return _c } -func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Return(_a0 *queryapi.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // CreateQueryWithResponse provides a mock function with given fields: ctx, body, reqEditors -func (_m *MockClientWithResponsesInterface) CreateQueryWithResponse(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) CreateQueryWithResponse(ctx context.Context, body queryapi.QueryCreate, reqEditors ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -265,20 +265,20 @@ func (_m *MockClientWithResponsesInterface) CreateQueryWithResponse(ctx context. panic("no return value specified for CreateQueryWithResponse") } - var r0 *queryservice.CreateQueryResponse + var r0 *queryapi.CreateQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error)); ok { return rf(ctx, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) *queryservice.CreateQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) *queryapi.CreateQueryResponse); ok { r0 = rf(ctx, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.CreateQueryResponse) + r0 = ret.Get(0).(*queryapi.CreateQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, body, reqEditors...) } else { r1 = ret.Error(1) @@ -294,38 +294,38 @@ type MockClientWithResponsesInterface_CreateQueryWithResponse_Call struct { // CreateQueryWithResponse is a helper method to define mock.On call // - ctx context.Context -// - body queryservice.QueryCreate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryCreate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) CreateQueryWithResponse(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { return &MockClientWithResponsesInterface_CreateQueryWithResponse_Call{Call: _e.mock.On("CreateQueryWithResponse", append([]interface{}{ctx, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Run(run func(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Run(run func(ctx context.Context, body queryapi.QueryCreate, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(queryservice.QueryCreate), variadicArgs...) + run(args[0].(context.Context), args[1].(queryapi.QueryCreate), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Return(_a0 *queryservice.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Return(_a0 *queryapi.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) RunAndReturn(run func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) RunAndReturn(run func(context.Context, queryapi.QueryCreate, ...queryapi.RequestEditorFn) (*queryapi.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { _c.Call.Return(run) return _c } // ExportStateWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) ExportStateWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error) { +func (_m *MockClientWithResponsesInterface) ExportStateWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*queryapi.ExportStateResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -339,20 +339,20 @@ func (_m *MockClientWithResponsesInterface) ExportStateWithResponse(ctx context. panic("no return value specified for ExportStateWithResponse") } - var r0 *queryservice.ExportStateResponse + var r0 *queryapi.ExportStateResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.ExportStateResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *queryservice.ExportStateResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *queryapi.ExportStateResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.ExportStateResponse) + r0 = ret.Get(0).(*queryapi.ExportStateResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -369,18 +369,18 @@ type MockClientWithResponsesInterface_ExportStateWithResponse_Call struct { // ExportStateWithResponse is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) ExportStateWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { return &MockClientWithResponsesInterface_ExportStateWithResponse_Call{Call: _e.mock.On("ExportStateWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) @@ -388,18 +388,18 @@ func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Run(run return _c } -func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Return(_a0 *queryservice.ExportStateResponse, _a1 error) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Return(_a0 *queryapi.ExportStateResponse, _a1 error) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.ExportStateResponse, error)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { _c.Call.Return(run) return _c } // GetClientWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) GetClientWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error) { +func (_m *MockClientWithResponsesInterface) GetClientWithResponse(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*queryapi.GetClientResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -413,20 +413,20 @@ func (_m *MockClientWithResponsesInterface) GetClientWithResponse(ctx context.Co panic("no return value specified for GetClientWithResponse") } - var r0 *queryservice.GetClientResponse + var r0 *queryapi.GetClientResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetClientResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetClientResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *queryapi.GetClientResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.GetClientResponse) + r0 = ret.Get(0).(*queryapi.GetClientResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -443,18 +443,18 @@ type MockClientWithResponsesInterface_GetClientWithResponse_Call struct { // GetClientWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) GetClientWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetClientWithResponse_Call { return &MockClientWithResponsesInterface_GetClientWithResponse_Call{Call: _e.mock.On("GetClientWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -462,18 +462,18 @@ func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Run(run f return _c } -func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Return(_a0 *queryservice.GetClientResponse, _a1 error) *MockClientWithResponsesInterface_GetClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Return(_a0 *queryapi.GetClientResponse, _a1 error) *MockClientWithResponsesInterface_GetClientWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetClientResponse, error)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { _c.Call.Return(run) return _c } // GetCollectorByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) GetCollectorByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error) { +func (_m *MockClientWithResponsesInterface) GetCollectorByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*queryapi.GetCollectorByClientIdResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -487,20 +487,20 @@ func (_m *MockClientWithResponsesInterface) GetCollectorByClientIdWithResponse(c panic("no return value specified for GetCollectorByClientIdWithResponse") } - var r0 *queryservice.GetCollectorByClientIdResponse + var r0 *queryapi.GetCollectorByClientIdResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetCollectorByClientIdResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetCollectorByClientIdResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *queryapi.GetCollectorByClientIdResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.GetCollectorByClientIdResponse) + r0 = ret.Get(0).(*queryapi.GetCollectorByClientIdResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -517,18 +517,18 @@ type MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call st // GetCollectorByClientIdWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) GetCollectorByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { return &MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call{Call: _e.mock.On("GetCollectorByClientIdWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -536,18 +536,92 @@ func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Ca return _c } -func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Return(_a0 *queryservice.GetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Return(_a0 *queryapi.GetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// GetDocumentWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) GetDocumentWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*queryapi.GetDocumentResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetDocumentWithResponse") + } + + var r0 *queryapi.GetDocumentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.GetDocumentResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *queryapi.GetDocumentResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryapi.GetDocumentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_GetDocumentWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDocumentWithResponse' +type MockClientWithResponsesInterface_GetDocumentWithResponse_Call struct { + *mock.Call +} + +// GetDocumentWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryapi.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) GetDocumentWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetDocumentWithResponse_Call { + return &MockClientWithResponsesInterface_GetDocumentWithResponse_Call{Call: _e.mock.On("GetDocumentWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_GetDocumentWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_GetDocumentWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryapi.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetDocumentWithResponse_Call) Return(_a0 *queryapi.GetDocumentResponse, _a1 error) *MockClientWithResponsesInterface_GetDocumentWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetDocumentWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.GetDocumentResponse, error)) *MockClientWithResponsesInterface_GetDocumentWithResponse_Call { _c.Call.Return(run) return _c } // GetQueryWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) GetQueryWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) GetQueryWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn) (*queryapi.GetQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -561,20 +635,20 @@ func (_m *MockClientWithResponsesInterface) GetQueryWithResponse(ctx context.Con panic("no return value specified for GetQueryWithResponse") } - var r0 *queryservice.GetQueryResponse + var r0 *queryapi.GetQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.GetQueryResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *queryservice.GetQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) *queryapi.GetQueryResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.GetQueryResponse) + r0 = ret.Get(0).(*queryapi.GetQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -591,18 +665,18 @@ type MockClientWithResponsesInterface_GetQueryWithResponse_Call struct { // GetQueryWithResponse is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) GetQueryWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { return &MockClientWithResponsesInterface_GetQueryWithResponse_Call{Call: _e.mock.On("GetQueryWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) @@ -610,18 +684,18 @@ func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Run(run fu return _c } -func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Return(_a0 *queryservice.GetQueryResponse, _a1 error) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Return(_a0 *queryapi.GetQueryResponse, _a1 error) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryapi.RequestEditorFn) (*queryapi.GetQueryResponse, error)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { _c.Call.Return(run) return _c } // GetStatusByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) GetStatusByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error) { +func (_m *MockClientWithResponsesInterface) GetStatusByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*queryapi.GetStatusByClientIdResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -635,20 +709,20 @@ func (_m *MockClientWithResponsesInterface) GetStatusByClientIdWithResponse(ctx panic("no return value specified for GetStatusByClientIdWithResponse") } - var r0 *queryservice.GetStatusByClientIdResponse + var r0 *queryapi.GetStatusByClientIdResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetStatusByClientIdResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetStatusByClientIdResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *queryapi.GetStatusByClientIdResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.GetStatusByClientIdResponse) + r0 = ret.Get(0).(*queryapi.GetStatusByClientIdResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -665,18 +739,18 @@ type MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call struc // GetStatusByClientIdWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) GetStatusByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { return &MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call{Call: _e.mock.On("GetStatusByClientIdWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -684,18 +758,18 @@ func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) return _c } -func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Return(_a0 *queryservice.GetStatusByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Return(_a0 *queryapi.GetStatusByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.GetStatusByClientIdResponse, error)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { _c.Call.Return(run) return _c } // ListDocumentsByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors -func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error) { +func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn) (*queryapi.ListDocumentsByClientIdResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -709,20 +783,20 @@ func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse( panic("no return value specified for ListDocumentsByClientIdWithResponse") } - var r0 *queryservice.ListDocumentsByClientIdResponse + var r0 *queryapi.ListDocumentsByClientIdResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.ListDocumentsByClientIdResponse, error)); ok { return rf(ctx, id, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.ListDocumentsByClientIdResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryapi.RequestEditorFn) *queryapi.ListDocumentsByClientIdResponse); ok { r0 = rf(ctx, id, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.ListDocumentsByClientIdResponse) + r0 = ret.Get(0).(*queryapi.ListDocumentsByClientIdResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, reqEditors...) } else { r1 = ret.Error(1) @@ -739,18 +813,18 @@ type MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call s // ListDocumentsByClientIdWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) ListDocumentsByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { return &MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call{Call: _e.mock.On("ListDocumentsByClientIdWithResponse", append([]interface{}{ctx, id}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-2) for i, a := range args[2:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), variadicArgs...) @@ -758,18 +832,18 @@ func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_C return _c } -func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Return(_a0 *queryservice.ListDocumentsByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Return(_a0 *queryapi.ListDocumentsByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryapi.RequestEditorFn) (*queryapi.ListDocumentsByClientIdResponse, error)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { _c.Call.Return(run) return _c } // ListQueriesWithResponse provides a mock function with given fields: ctx, reqEditors -func (_m *MockClientWithResponsesInterface) ListQueriesWithResponse(ctx context.Context, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error) { +func (_m *MockClientWithResponsesInterface) ListQueriesWithResponse(ctx context.Context, reqEditors ...queryapi.RequestEditorFn) (*queryapi.ListQueriesResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -783,20 +857,20 @@ func (_m *MockClientWithResponsesInterface) ListQueriesWithResponse(ctx context. panic("no return value specified for ListQueriesWithResponse") } - var r0 *queryservice.ListQueriesResponse + var r0 *queryapi.ListQueriesResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) (*queryapi.ListQueriesResponse, error)); ok { return rf(ctx, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) *queryservice.ListQueriesResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) *queryapi.ListQueriesResponse); ok { r0 = rf(ctx, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.ListQueriesResponse) + r0 = ret.Get(0).(*queryapi.ListQueriesResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, reqEditors...) } else { r1 = ret.Error(1) @@ -812,18 +886,18 @@ type MockClientWithResponsesInterface_ListQueriesWithResponse_Call struct { // ListQueriesWithResponse is a helper method to define mock.On call // - ctx context.Context -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) ListQueriesWithResponse(ctx interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { return &MockClientWithResponsesInterface_ListQueriesWithResponse_Call{Call: _e.mock.On("ListQueriesWithResponse", append([]interface{}{ctx}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Run(run func(ctx context.Context, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Run(run func(ctx context.Context, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-1) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-1) for i, a := range args[1:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), variadicArgs...) @@ -831,18 +905,18 @@ func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Run(run return _c } -func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Return(_a0 *queryservice.ListQueriesResponse, _a1 error) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Return(_a0 *queryapi.ListQueriesResponse, _a1 error) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) RunAndReturn(run func(context.Context, ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) RunAndReturn(run func(context.Context, ...queryapi.RequestEditorFn) (*queryapi.ListQueriesResponse, error)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { _c.Call.Return(run) return _c } // SetCollectorByClientIdWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error) { +func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -856,20 +930,20 @@ func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithBodyWithRe panic("no return value specified for SetCollectorByClientIdWithBodyWithResponse") } - var r0 *queryservice.SetCollectorByClientIdResponse + var r0 *queryapi.SetCollectorByClientIdResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.SetCollectorByClientIdResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.SetCollectorByClientIdResponse); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.SetCollectorByClientIdResponse) + r0 = ret.Get(0).(*queryapi.SetCollectorByClientIdResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -888,18 +962,18 @@ type MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) SetCollectorByClientIdWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call{Call: _e.mock.On("SetCollectorByClientIdWithBodyWithResponse", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -907,18 +981,18 @@ func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithRes return _c } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Return(_a0 *queryservice.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Return(_a0 *queryapi.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // SetCollectorByClientIdWithResponse provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithResponse(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error) { +func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithResponse(ctx context.Context, id string, body queryapi.CollectorSet, reqEditors ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -932,20 +1006,20 @@ func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithResponse(c panic("no return value specified for SetCollectorByClientIdWithResponse") } - var r0 *queryservice.SetCollectorByClientIdResponse + var r0 *queryapi.SetCollectorByClientIdResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) *queryservice.SetCollectorByClientIdResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) *queryapi.SetCollectorByClientIdResponse); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.SetCollectorByClientIdResponse) + r0 = ret.Get(0).(*queryapi.SetCollectorByClientIdResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -962,38 +1036,38 @@ type MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call st // SetCollectorByClientIdWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.CollectorSet -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.CollectorSet +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) SetCollectorByClientIdWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { return &MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call{Call: _e.mock.On("SetCollectorByClientIdWithResponse", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, body queryapi.CollectorSet, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.CollectorSet), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.CollectorSet), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Return(_a0 *queryservice.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Return(_a0 *queryapi.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, queryapi.CollectorSet, ...queryapi.RequestEditorFn) (*queryapi.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { _c.Call.Return(run) return _c } // TestQueryWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) TestQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) TestQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1007,20 +1081,20 @@ func (_m *MockClientWithResponsesInterface) TestQueryWithBodyWithResponse(ctx co panic("no return value specified for TestQueryWithBodyWithResponse") } - var r0 *queryservice.TestQueryResponse + var r0 *queryapi.TestQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.TestQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.TestQueryResponse); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.TestQueryResponse) + r0 = ret.Get(0).(*queryapi.TestQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1039,18 +1113,18 @@ type MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call struct // - id uuid.UUID // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) TestQueryWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call{Call: _e.mock.On("TestQueryWithBodyWithResponse", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1058,18 +1132,18 @@ func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) R return _c } -func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Return(_a0 *queryapi.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // TestQueryWithResponse provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientWithResponsesInterface) TestQueryWithResponse(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) TestQueryWithResponse(ctx context.Context, id uuid.UUID, body queryapi.QueryTestRequest, reqEditors ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1083,20 +1157,20 @@ func (_m *MockClientWithResponsesInterface) TestQueryWithResponse(ctx context.Co panic("no return value specified for TestQueryWithResponse") } - var r0 *queryservice.TestQueryResponse + var r0 *queryapi.TestQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) *queryservice.TestQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) *queryapi.TestQueryResponse); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.TestQueryResponse) + r0 = ret.Get(0).(*queryapi.TestQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1113,38 +1187,38 @@ type MockClientWithResponsesInterface_TestQueryWithResponse_Call struct { // TestQueryWithResponse is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - body queryservice.QueryTestRequest -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryTestRequest +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) TestQueryWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { return &MockClientWithResponsesInterface_TestQueryWithResponse_Call{Call: _e.mock.On("TestQueryWithResponse", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryapi.QueryTestRequest, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryTestRequest), variadicArgs...) + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryapi.QueryTestRequest), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Return(_a0 *queryservice.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Return(_a0 *queryapi.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryapi.QueryTestRequest, ...queryapi.RequestEditorFn) (*queryapi.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { _c.Call.Return(run) return _c } // TriggerExportWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) TriggerExportWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error) { +func (_m *MockClientWithResponsesInterface) TriggerExportWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1158,20 +1232,20 @@ func (_m *MockClientWithResponsesInterface) TriggerExportWithBodyWithResponse(ct panic("no return value specified for TriggerExportWithBodyWithResponse") } - var r0 *queryservice.TriggerExportResponse + var r0 *queryapi.TriggerExportResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.TriggerExportResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.TriggerExportResponse); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.TriggerExportResponse) + r0 = ret.Get(0).(*queryapi.TriggerExportResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1190,18 +1264,18 @@ type MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call str // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) TriggerExportWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call{Call: _e.mock.On("TriggerExportWithBodyWithResponse", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1209,18 +1283,18 @@ func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Cal return _c } -func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Return(_a0 *queryservice.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Return(_a0 *queryapi.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // TriggerExportWithResponse provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientWithResponsesInterface) TriggerExportWithResponse(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error) { +func (_m *MockClientWithResponsesInterface) TriggerExportWithResponse(ctx context.Context, id string, body queryapi.ExportTrigger, reqEditors ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1234,20 +1308,20 @@ func (_m *MockClientWithResponsesInterface) TriggerExportWithResponse(ctx contex panic("no return value specified for TriggerExportWithResponse") } - var r0 *queryservice.TriggerExportResponse + var r0 *queryapi.TriggerExportResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) *queryservice.TriggerExportResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) *queryapi.TriggerExportResponse); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.TriggerExportResponse) + r0 = ret.Get(0).(*queryapi.TriggerExportResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1264,38 +1338,38 @@ type MockClientWithResponsesInterface_TriggerExportWithResponse_Call struct { // TriggerExportWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.ExportTrigger -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ExportTrigger +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) TriggerExportWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { return &MockClientWithResponsesInterface_TriggerExportWithResponse_Call{Call: _e.mock.On("TriggerExportWithResponse", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Run(run func(ctx context.Context, id string, body queryapi.ExportTrigger, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ExportTrigger), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.ExportTrigger), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Return(_a0 *queryservice.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Return(_a0 *queryapi.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) RunAndReturn(run func(context.Context, string, queryapi.ExportTrigger, ...queryapi.RequestEditorFn) (*queryapi.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { _c.Call.Return(run) return _c } // UpdateClientWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) UpdateClientWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error) { +func (_m *MockClientWithResponsesInterface) UpdateClientWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1309,20 +1383,20 @@ func (_m *MockClientWithResponsesInterface) UpdateClientWithBodyWithResponse(ctx panic("no return value specified for UpdateClientWithBodyWithResponse") } - var r0 *queryservice.UpdateClientResponse + var r0 *queryapi.UpdateClientResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.UpdateClientResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.UpdateClientResponse); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.UpdateClientResponse) + r0 = ret.Get(0).(*queryapi.UpdateClientResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1341,18 +1415,18 @@ type MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call stru // - id string // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) UpdateClientWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call{Call: _e.mock.On("UpdateClientWithBodyWithResponse", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1360,18 +1434,18 @@ func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call return _c } -func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Return(_a0 *queryservice.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Return(_a0 *queryapi.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // UpdateClientWithResponse provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientWithResponsesInterface) UpdateClientWithResponse(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error) { +func (_m *MockClientWithResponsesInterface) UpdateClientWithResponse(ctx context.Context, id string, body queryapi.ClientUpdate, reqEditors ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1385,20 +1459,20 @@ func (_m *MockClientWithResponsesInterface) UpdateClientWithResponse(ctx context panic("no return value specified for UpdateClientWithResponse") } - var r0 *queryservice.UpdateClientResponse + var r0 *queryapi.UpdateClientResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) *queryservice.UpdateClientResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) *queryapi.UpdateClientResponse); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.UpdateClientResponse) + r0 = ret.Get(0).(*queryapi.UpdateClientResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1415,38 +1489,38 @@ type MockClientWithResponsesInterface_UpdateClientWithResponse_Call struct { // UpdateClientWithResponse is a helper method to define mock.On call // - ctx context.Context // - id string -// - body queryservice.ClientUpdate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.ClientUpdate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) UpdateClientWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { return &MockClientWithResponsesInterface_UpdateClientWithResponse_Call{Call: _e.mock.On("UpdateClientWithResponse", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Run(run func(ctx context.Context, id string, body queryapi.ClientUpdate, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ClientUpdate), variadicArgs...) + run(args[0].(context.Context), args[1].(string), args[2].(queryapi.ClientUpdate), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Return(_a0 *queryservice.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Return(_a0 *queryapi.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) RunAndReturn(run func(context.Context, string, queryapi.ClientUpdate, ...queryapi.RequestEditorFn) (*queryapi.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { _c.Call.Return(run) return _c } // UpdateQueryWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors -func (_m *MockClientWithResponsesInterface) UpdateQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) UpdateQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1460,20 +1534,20 @@ func (_m *MockClientWithResponsesInterface) UpdateQueryWithBodyWithResponse(ctx panic("no return value specified for UpdateQueryWithBodyWithResponse") } - var r0 *queryservice.UpdateQueryResponse + var r0 *queryapi.UpdateQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error)); ok { return rf(ctx, id, contentType, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.UpdateQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) *queryapi.UpdateQueryResponse); ok { r0 = rf(ctx, id, contentType, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.UpdateQueryResponse) + r0 = ret.Get(0).(*queryapi.UpdateQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, contentType, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1492,18 +1566,18 @@ type MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call struc // - id uuid.UUID // - contentType string // - body io.Reader -// - reqEditors ...queryservice.RequestEditorFn +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) UpdateQueryWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { return &MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call{Call: _e.mock.On("UpdateQueryWithBodyWithResponse", append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-4) for i, a := range args[4:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) @@ -1511,18 +1585,18 @@ func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) return _c } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Return(_a0 *queryapi.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { _c.Call.Return(run) return _c } // UpdateQueryWithResponse provides a mock function with given fields: ctx, id, body, reqEditors -func (_m *MockClientWithResponsesInterface) UpdateQueryWithResponse(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error) { +func (_m *MockClientWithResponsesInterface) UpdateQueryWithResponse(ctx context.Context, id uuid.UUID, body queryapi.QueryUpdate, reqEditors ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error) { _va := make([]interface{}, len(reqEditors)) for _i := range reqEditors { _va[_i] = reqEditors[_i] @@ -1536,20 +1610,20 @@ func (_m *MockClientWithResponsesInterface) UpdateQueryWithResponse(ctx context. panic("no return value specified for UpdateQueryWithResponse") } - var r0 *queryservice.UpdateQueryResponse + var r0 *queryapi.UpdateQueryResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error)); ok { return rf(ctx, id, body, reqEditors...) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) *queryservice.UpdateQueryResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) *queryapi.UpdateQueryResponse); ok { r0 = rf(ctx, id, body, reqEditors...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*queryservice.UpdateQueryResponse) + r0 = ret.Get(0).(*queryapi.UpdateQueryResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) error); ok { r1 = rf(ctx, id, body, reqEditors...) } else { r1 = ret.Error(1) @@ -1566,32 +1640,32 @@ type MockClientWithResponsesInterface_UpdateQueryWithResponse_Call struct { // UpdateQueryWithResponse is a helper method to define mock.On call // - ctx context.Context // - id uuid.UUID -// - body queryservice.QueryUpdate -// - reqEditors ...queryservice.RequestEditorFn +// - body queryapi.QueryUpdate +// - reqEditors ...queryapi.RequestEditorFn func (_e *MockClientWithResponsesInterface_Expecter) UpdateQueryWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { return &MockClientWithResponsesInterface_UpdateQueryWithResponse_Call{Call: _e.mock.On("UpdateQueryWithResponse", append([]interface{}{ctx, id, body}, reqEditors...)...)} } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryapi.QueryUpdate, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + variadicArgs := make([]queryapi.RequestEditorFn, len(args)-3) for i, a := range args[3:] { if a != nil { - variadicArgs[i] = a.(queryservice.RequestEditorFn) + variadicArgs[i] = a.(queryapi.RequestEditorFn) } } - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryUpdate), variadicArgs...) + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryapi.QueryUpdate), variadicArgs...) }) return _c } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Return(_a0 *queryservice.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Return(_a0 *queryapi.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryapi.QueryUpdate, ...queryapi.RequestEditorFn) (*queryapi.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { _c.Call.Return(run) return _c } diff --git a/pkg/queryService/api.gen.go b/pkg/queryAPI/api.gen.go similarity index 94% rename from pkg/queryService/api.gen.go rename to pkg/queryAPI/api.gen.go index d88c069f..2471b452 100644 --- a/pkg/queryService/api.gen.go +++ b/pkg/queryAPI/api.gen.go @@ -1,7 +1,7 @@ -// Package queryservice provides primitives to interact with the openapi HTTP API. +// Package queryapi provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version 2.4.1 DO NOT EDIT. -package queryservice +package queryapi import ( "bytes" @@ -170,19 +170,31 @@ type DocClient struct { // Document The document properties. type Document struct { - // Bucket The bucket containing the document - Bucket string `json:"bucket"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` + + // Fields The fields and the value for the document + Fields map[string]interface{} `json:"fields"` + + // Hash The document hash + Hash Hash `json:"hash"` // Id The document id. Id DocumentID `json:"id"` - - // Key The path to the document - Key string `json:"key"` } // DocumentID The document id. type DocumentID = openapi_types.UUID +// DocumentSummary The document properties. +type DocumentSummary struct { + // Hash The document hash + Hash Hash `json:"hash"` + + // Id The document id. + Id DocumentID `json:"id"` +} + // ExportDetails Payload for export trigger response. type ExportDetails struct { // ClientId The client external id @@ -231,6 +243,9 @@ type FieldFilter struct { // FieldFilterCondition The possible field filtering conditions. type FieldFilterCondition string +// Hash The document hash +type Hash = string + // IdMessage A single uuid. type IdMessage struct { // Id Unique identifier for entity. @@ -238,7 +253,7 @@ type IdMessage struct { } // ListDocuments The documents in the client. -type ListDocuments = []Document +type ListDocuments = []DocumentSummary // ListQueries A set of queries. type ListQueries struct { @@ -447,6 +462,9 @@ type ClientInterface interface { // GetStatusByClientId request GetStatusByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetDocument request + GetDocument(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*http.Response, error) + // ExportState request ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -616,6 +634,18 @@ func (c *Client) GetStatusByClientId(ctx context.Context, id ClientID, reqEditor return c.Client.Do(req) } +func (c *Client) GetDocument(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetDocumentRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewExportStateRequest(c.Server, id) if err != nil { @@ -1041,6 +1071,40 @@ func NewGetStatusByClientIdRequest(server string, id ClientID) (*http.Request, e return req, nil } +// NewGetDocumentRequest generates requests for GetDocument +func NewGetDocumentRequest(server string, id DocumentID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/document/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewExportStateRequest generates requests for ExportState func NewExportStateRequest(server string, id ExportID) (*http.Request, error) { var err error @@ -1345,6 +1409,9 @@ type ClientWithResponsesInterface interface { // GetStatusByClientIdWithResponse request GetStatusByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetStatusByClientIdResponse, error) + // GetDocumentWithResponse request + GetDocumentWithResponse(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) + // ExportStateWithResponse request ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) @@ -1544,6 +1611,28 @@ func (r GetStatusByClientIdResponse) StatusCode() int { return 0 } +type GetDocumentResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Document +} + +// Status returns HTTPResponse.Status +func (r GetDocumentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetDocumentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ExportStateResponse struct { Body []byte HTTPResponse *http.Response @@ -1779,6 +1868,15 @@ func (c *ClientWithResponses) GetStatusByClientIdWithResponse(ctx context.Contex return ParseGetStatusByClientIdResponse(rsp) } +// GetDocumentWithResponse request returning *GetDocumentResponse +func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, id DocumentID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) { + rsp, err := c.GetDocument(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetDocumentResponse(rsp) +} + // ExportStateWithResponse request returning *ExportStateResponse func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) { rsp, err := c.ExportState(ctx, id, reqEditors...) @@ -2045,6 +2143,32 @@ func ParseGetStatusByClientIdResponse(rsp *http.Response) (*GetStatusByClientIdR return response, nil } +// ParseGetDocumentResponse parses an HTTP response from a GetDocumentWithResponse call +func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetDocumentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Document + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseExportStateResponse parses an HTTP response from a ExportStateWithResponse call func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/scripts/database.yml b/scripts/database.yml index a2f4a1b8..8dc2ff46 100644 --- a/scripts/database.yml +++ b/scripts/database.yml @@ -21,6 +21,13 @@ tasks: cmds: - task compose:up:generate - sqlc vet --file sqlc.yml + - | + exit 0 + for file in database/migrations/*.sql; do + if [[ -f "$file" ]]; then + sqlcheck -c -f $file -r 3 # move to 1 + fi + done mig:create: cmds: - | diff --git a/scripts/openapi-scripts.yml b/scripts/openapi-scripts.yml index b93a9ab4..dce1f645 100644 --- a/scripts/openapi-scripts.yml +++ b/scripts/openapi-scripts.yml @@ -7,8 +7,12 @@ tasks: lint: cmds: - | - vacuum lint ./serviceAPIs/queryService.yaml -b -d -e --no-clip -z \ - {{.CLI_ARGS}} + for file in serviceAPIs/*.yml serviceAPIs/*.yaml; do + if [[ -f "$file" ]]; then + vacuum lint $file -b -d -e --no-clip -z \ + {{.CLI_ARGS}} + fi + done generate: - | generateGo() { diff --git a/serviceAPIs/queryService.yaml b/serviceAPIs/queryAPI.yaml similarity index 92% rename from serviceAPIs/queryService.yaml rename to serviceAPIs/queryAPI.yaml index a6293a20..76714c86 100644 --- a/serviceAPIs/queryService.yaml +++ b/serviceAPIs/queryAPI.yaml @@ -14,7 +14,7 @@ tags: description: Operations related to collectors - name: DocumentsService description: Operations related to documents - - name: QueryService + - name: QueryAPI description: Operations related to queries - name: ExportService description: Operations related to exports @@ -106,7 +106,7 @@ paths: get: operationId: listQueries tags: - - QueryService + - QueryAPI summary: List queries description: Retrieves a list of queries based on filter criteria. security: @@ -128,7 +128,7 @@ paths: post: operationId: createQuery tags: - - QueryService + - QueryAPI summary: Create a new query description: Creates a new query with the provided details. security: @@ -161,7 +161,7 @@ paths: get: operationId: getQuery tags: - - QueryService + - QueryAPI summary: Get a query by ID description: Retrieves a specific query by its ID. security: @@ -183,7 +183,7 @@ paths: patch: operationId: updateQuery tags: - - QueryService + - QueryAPI summary: Update a query description: Updates an existing query with new details. security: @@ -212,7 +212,7 @@ paths: post: operationId: testQuery tags: - - QueryService + - QueryAPI summary: Test a query description: Executes a test run of a query with the provided parameters. security: @@ -342,6 +342,32 @@ paths: "500": $ref: "#/components/responses/InternalError" + /document/{id}: + parameters: + - $ref: "#/components/parameters/DocumentID" + get: + operationId: getDocument + tags: + - DocumentsService + summary: Get document details by its id + description: Retrieves the details of a document by its id. + security: + - placeholderAuth: [] + responses: + "200": + description: Document details. + headers: + RateLimit: + $ref: "#/components/headers/RateLimit" + content: + application/json: + schema: + $ref: "#/components/schemas/Document" + "400": + $ref: "#/components/responses/InvalidRequest" + "500": + $ref: "#/components/responses/InternalError" + /client/{id}/export: parameters: - $ref: "#/components/parameters/ClientID" @@ -427,6 +453,14 @@ components: $ref: "#/components/schemas/QueryID" description: The ID of the query. + DocumentID: + in: path + name: id + required: true + schema: + $ref: "#/components/schemas/DocumentID" + description: The document ID. + headers: RateLimit: schema: @@ -655,7 +689,25 @@ components: description: The documents in the client. maxItems: 256 items: - $ref: "#/components/schemas/Document" + $ref: "#/components/schemas/DocumentSummary" + + Hash: + type: string + description: The document hash + maxLength: 2048 + pattern: "^.+$" + + DocumentSummary: + description: The document properties. + type: object + properties: + id: + $ref: "#/components/schemas/DocumentID" + hash: + $ref: "#/components/schemas/Hash" + required: + - id + - hash Document: description: The document properties. @@ -663,20 +715,26 @@ components: properties: id: $ref: "#/components/schemas/DocumentID" - bucket: - type: string - description: The bucket containing the document - maxLength: 256 - pattern: "^.+$" - key: - type: string - description: The path to the document - maxLength: 2048 - pattern: "^.+/.+$" + client_id: + $ref: "#/components/schemas/ClientID" + hash: + $ref: "#/components/schemas/Hash" + fields: + type: object + description: "The fields and the value for the document" + additionalProperties: true + example: + property1: "string value" + property2: 42 + property3: true + property4: + nestedProperty: "nested value" + property5: [1, 2, 3] required: - id - - bucket - - key + - client_id + - hash + - fields ClientCreate: description: The properties for creation. diff --git a/test/process_test.go b/test/process_test.go index c91b3b82..3d1c3767 100644 --- a/test/process_test.go +++ b/test/process_test.go @@ -2,16 +2,14 @@ package endtoend_test import ( "context" - "fmt" "strings" "testing" - "time" "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/objectstore" "queryorchestration/internal/test" - queryservicetest "queryorchestration/internal/test/queryService" - queryservice "queryorchestration/pkg/queryService" + queryapitest "queryorchestration/internal/test/queryAPI" + queryapi "queryorchestration/pkg/queryAPI" "github.com/oapi-codegen/runtime/types" "github.com/stretchr/testify/assert" @@ -32,23 +30,23 @@ func TestProcess(t *testing.T) { net, clean := test.CreateFullNetwork(t, ctx, cfg) defer clean() - client := queryservicetest.CreateClientWithSync(t, ctx, net.Client) + client := queryapitest.CreateClientWithSync(t, ctx, net.Client) - contextQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.CONTEXTFULL, + contextQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.CONTEXTFULL, }) require.NoError(t, err) jcfg := `{"path":"keyone"}` - jsonQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.JSONEXTRACTOR, + jsonQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.JSONEXTRACTOR, Config: &jcfg, RequiredQueries: &[]types.UUID{contextQueryRes.JSON201.Id}, }) require.NoError(t, err) newActiveVersion := int32(1) - _, err = net.Client.SetCollectorByClientIdWithResponse(ctx, client.Id, queryservice.CollectorSet{ + _, err = net.Client.SetCollectorByClientIdWithResponse(ctx, client.Id, queryapi.CollectorSet{ ActiveVersion: &newActiveVersion, - Fields: &[]queryservice.CollectorField{ + Fields: &[]queryapi.CollectorField{ { Name: "JSON_QUERY", QueryId: jsonQueryRes.JSON201.Id, @@ -57,71 +55,73 @@ func TestProcess(t *testing.T) { }) require.NoError(t, err) - WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) + queryapitest.WaitForClientStatus(t, ctx, net.Client, client.Id, queryapi.INSYNC) body := strings.NewReader(pdfHelloWorld) - location := test.PutObject(t, ctx, cfg, client.Uid, net.Dependencies.BucketName, "object_name", body) + test.PutObject(t, ctx, cfg, client.Uid, net.Dependencies.BucketName, "object_name", body) - WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.NOTSYNCED) - WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) + queryapitest.WaitForClientStatus(t, ctx, net.Client, client.Id, queryapi.NOTSYNCED) + queryapitest.WaitForClientStatus(t, ctx, net.Client, client.Id, queryapi.INSYNC) docs, err := net.Client.ListDocumentsByClientIdWithResponse(ctx, client.Id) - assert.NoError(t, err) + require.NoError(t, err) assert.Len(t, *docs.JSON200, 1) doc := (*docs.JSON200)[0] - assert.Equal(t, net.Dependencies.BucketName, doc.Bucket) - assert.Equal(t, location, doc.Key) - testRes, err := net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ + expectedDoc := queryapi.Document{ + Id: doc.Id, + Hash: doc.Hash, + ClientId: client.Id, + Fields: map[string]interface{}{ + "JSON_QUERY": "valueone", + }, + } + + docRes, err := net.Client.GetDocumentWithResponse(ctx, doc.Id) + require.NoError(t, err) + require.NotNil(t, docRes) + require.NotNil(t, docRes.JSON200) + fullDoc := *docRes.JSON200 + assert.EqualExportedValues(t, expectedDoc, fullDoc) + + jcfg = `{"path":"keytwo"}` + av := int32(2) + _, err = net.Client.UpdateQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryapi.QueryUpdate{ + ActiveVersion: &av, + Config: &jcfg, + }) + require.NoError(t, err) + expectedDoc.Fields = map[string]interface{}{ + "JSON_QUERY": "valuetwo", + } + + queryapitest.WaitForClientStatus(t, ctx, net.Client, client.Id, queryapi.NOTSYNCED) + queryapitest.WaitForClientStatus(t, ctx, net.Client, client.Id, queryapi.INSYNC) + + docRes, err = net.Client.GetDocumentWithResponse(ctx, doc.Id) + require.NoError(t, err) + require.NotNil(t, docRes) + require.NotNil(t, docRes.JSON200) + assert.EqualExportedValues(t, expectedDoc, *docRes.JSON200) + + testRes, err := net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryapi.QueryTestRequest{ QueryVersion: 1, DocumentId: doc.Id, }) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, "valueone", testRes.JSON200.Value) - - aV := int32(2) - jcfg = `{"path":"keytwo"}` - res, err := net.Client.UpdateQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryUpdate{ - ActiveVersion: &aV, - Config: &jcfg, - }) - assert.NoError(t, err) - assert.NotNil(t, res) - - WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.NOTSYNCED) - WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) - - testRes, err = net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ + testRes, err = net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryapi.QueryTestRequest{ QueryVersion: 2, DocumentId: doc.Id, }) assert.NoError(t, err) assert.Equal(t, "valuetwo", testRes.JSON200.Value) -} -func WaitForClientStatus(t testing.TB, ctx context.Context, service *queryservice.ClientWithResponses, id string, status queryservice.ClientStatus) { - t.Helper() - - timeout := time.After(30 * time.Second) - ticker := time.NewTicker(500 * time.Millisecond) - defer ticker.Stop() - - for { - select { - case <-timeout: - require.NoError(t, fmt.Errorf("Timeout waiting for client status to become %s", status)) - case <-ticker.C: - jRes, err := service.GetStatusByClientIdWithResponse(ctx, id) - if err != nil { - assert.NoError(t, err) - } - - if jRes.JSON200.Status == status { - assert.Equal(t, status, jRes.JSON200.Status) - return - } - } - } + docRes, err = net.Client.GetDocumentWithResponse(ctx, doc.Id) + require.NoError(t, err) + require.NotNil(t, docRes) + require.NotNil(t, docRes.JSON200) + assert.EqualExportedValues(t, expectedDoc, *docRes.JSON200) } const pdfHelloWorld = `%PDF-1.4 diff --git a/test/queryService/accessory_test.go b/test/queryAPI/accessory_test.go similarity index 76% rename from test/queryService/accessory_test.go rename to test/queryAPI/accessory_test.go index f971a243..271f5609 100644 --- a/test/queryService/accessory_test.go +++ b/test/queryAPI/accessory_test.go @@ -11,15 +11,11 @@ import ( "github.com/stretchr/testify/assert" ) -func TestQueryServiceAccessories(t *testing.T) { +func TestQueryAPIAccessories(t *testing.T) { ctx := context.Background() - c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "iamthere", - }, + c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{ + API: test.QueryAPI, }) defer cleanup() diff --git a/test/queryService/client_test.go b/test/queryAPI/client_test.go similarity index 71% rename from test/queryService/client_test.go rename to test/queryAPI/client_test.go index e6d37f81..d26985d3 100644 --- a/test/queryService/client_test.go +++ b/test/queryAPI/client_test.go @@ -5,7 +5,7 @@ import ( "testing" "queryorchestration/internal/test" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" "github.com/stretchr/testify/assert" ) @@ -13,19 +13,15 @@ import ( func TestClient(t *testing.T) { ctx := context.Background() - c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "iamthere", - }, + c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{ + API: test.QueryAPI, }) defer cleanup() - client, err := queryservice.NewClientWithResponses(c.URI) + client, err := queryapi.NewClientWithResponses(c.URI) assert.NoError(t, err) - idRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ + idRes, err := client.CreateClientWithResponse(ctx, queryapi.ClientCreate{ Name: "example_name", Id: "EXA", }) @@ -43,7 +39,7 @@ func TestClient(t *testing.T) { updateName := "update_name" updateCanSync := true - updateRes, err := client.UpdateClientWithResponse(ctx, id, queryservice.ClientUpdate{ + updateRes, err := client.UpdateClientWithResponse(ctx, id, queryapi.ClientUpdate{ Name: &updateName, CanSync: &updateCanSync, }) diff --git a/test/queryService/collectorservice_test.go b/test/queryAPI/collectorservice_test.go similarity index 77% rename from test/queryService/collectorservice_test.go rename to test/queryAPI/collectorservice_test.go index 1e7420bf..f3186012 100644 --- a/test/queryService/collectorservice_test.go +++ b/test/queryAPI/collectorservice_test.go @@ -8,7 +8,7 @@ import ( "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/queue" "queryorchestration/internal/test" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" "github.com/oapi-codegen/runtime/types" "github.com/stretchr/testify/assert" @@ -35,30 +35,26 @@ func TestCollectorService(t *testing.T) { defer clean() test.SetQueueClient(t, ctx, cfg) - clientsyncurl := test.CreateQueue(t, ctx, cfg, test.ClientSyncRunner) + clientsyncurl := test.CreateQueue(t, ctx, cfg, test.ClientSyncRunnerName) - c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ + c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{ Cfg: cfg, Network: network, - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": clientsyncurl, - "QUERY_VERSION_SYNC_URL": "iamthere", - }, + API: test.QueryAPI, }) defer cleanup() - client, err := queryservice.NewClientWithResponses(c.URI) + client, err := queryapi.NewClientWithResponses(c.URI) assert.NoError(t, err) - contextRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.CONTEXTFULL, + contextRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.CONTEXTFULL, }) assert.NoError(t, err) jsoncfg := "{\"path\":\"key\"}" - jsonRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.JSONEXTRACTOR, + jsonRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.JSONEXTRACTOR, Config: &jsoncfg, RequiredQueries: &[]types.UUID{ contextRes.JSON201.Id, @@ -66,7 +62,7 @@ func TestCollectorService(t *testing.T) { }) assert.NoError(t, err) - clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ + clientRes, err := client.CreateClientWithResponse(ctx, queryapi.ClientCreate{ Name: "example_name", Id: "ID", }) @@ -83,14 +79,14 @@ func TestCollectorService(t *testing.T) { assert.Len(t, collRes.JSON200.Fields, 0) av := int32(1) - fields := []queryservice.CollectorField{ + fields := []queryapi.CollectorField{ { Name: "json", QueryId: jsonRes.JSON201.Id, }, } minVersion := int64(1000) - uRes, err := client.SetCollectorByClientIdWithResponse(ctx, id, queryservice.CollectorSet{ + uRes, err := client.SetCollectorByClientIdWithResponse(ctx, id, queryapi.CollectorSet{ ActiveVersion: &av, MinimumCleanerVersion: &minVersion, MinimumTextVersion: &minVersion, diff --git a/test/queryAPI/exportservice_test.go b/test/queryAPI/exportservice_test.go new file mode 100644 index 00000000..e28f5b07 --- /dev/null +++ b/test/queryAPI/exportservice_test.go @@ -0,0 +1,27 @@ +package endtoend + +import ( + "context" + "testing" + + "queryorchestration/internal/test" + queryapi "queryorchestration/pkg/queryAPI" + + "github.com/stretchr/testify/assert" +) + +func TestExportService(t *testing.T) { + ctx := context.Background() + + c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{ + API: test.QueryAPI, + }) + defer cleanup() + + client, err := queryapi.NewClientWithResponses(c.URI) + assert.NoError(t, err) + + idRes, err := client.TriggerExportWithResponse(ctx, "CLIENT_ID", queryapi.ExportTrigger{}) + assert.NoError(t, err) + assert.NotNil(t, idRes) +} diff --git a/test/queryService/queryservice_test.go b/test/queryAPI/queryservice_test.go similarity index 72% rename from test/queryService/queryservice_test.go rename to test/queryAPI/queryservice_test.go index 7863c73d..23c0574c 100644 --- a/test/queryService/queryservice_test.go +++ b/test/queryAPI/queryservice_test.go @@ -10,7 +10,7 @@ import ( "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/queue" "queryorchestration/internal/test" - queryservice "queryorchestration/pkg/queryService" + queryapi "queryorchestration/pkg/queryAPI" "github.com/oapi-codegen/runtime/types" "github.com/stretchr/testify/assert" @@ -21,7 +21,7 @@ type QueryConfig struct { queue.QueueConfig } -func TestQueryService(t *testing.T) { +func TestQueryAPI(t *testing.T) { ctx := context.Background() cfg := &QueryConfig{} @@ -39,24 +39,20 @@ func TestQueryService(t *testing.T) { err := cfg.SetQueueClient(ctx) assert.NoError(t, err) - queryversionsyncurl := test.CreateQueue(t, ctx, cfg, test.QueryVersionSyncRunner) + queryversionsyncurl := test.CreateQueue(t, ctx, cfg, test.QueryVersionSyncRunnerName) - c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ + c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{ Cfg: cfg, Network: network, - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": queryversionsyncurl, - }, + API: test.QueryAPI, }) defer cleanup() - client, err := queryservice.NewClientWithResponses(c.URI) + client, err := queryapi.NewClientWithResponses(c.URI) assert.NoError(t, err) - idRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.CONTEXTFULL, + idRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.CONTEXTFULL, }) assert.NoError(t, err) assert.NotNil(t, idRes) @@ -65,8 +61,8 @@ func TestQueryService(t *testing.T) { assert.NotEmpty(t, contextID) jcfg := "{}" - idRes, err = client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ - Type: queryservice.JSONEXTRACTOR, + idRes, err = client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{ + Type: queryapi.JSONEXTRACTOR, Config: &jcfg, }) assert.NoError(t, err) @@ -75,7 +71,7 @@ func TestQueryService(t *testing.T) { queryRes, err := client.GetQueryWithResponse(ctx, jsonID) assert.NoError(t, err) assert.Equal(t, jsonID, queryRes.JSON200.Id) - assert.Equal(t, queryservice.JSONEXTRACTOR, queryRes.JSON200.Type) + assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type) assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion) assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion) assert.Equal(t, jcfg, *queryRes.JSON200.Config) @@ -86,7 +82,7 @@ func TestQueryService(t *testing.T) { assert.Len(t, queriesRes.JSON200.Queries, 2) aV := int32(2) - res, err := client.UpdateQueryWithResponse(ctx, jsonID, queryservice.QueryUpdate{ + res, err := client.UpdateQueryWithResponse(ctx, jsonID, queryapi.QueryUpdate{ ActiveVersion: &aV, RequiredQueries: &[]types.UUID{ contextID, @@ -100,7 +96,7 @@ func TestQueryService(t *testing.T) { queryRes, err = client.GetQueryWithResponse(ctx, jsonID) assert.NoError(t, err) assert.Equal(t, jsonID, queryRes.JSON200.Id) - assert.Equal(t, queryservice.JSONEXTRACTOR, queryRes.JSON200.Type) + assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type) assert.Equal(t, int32(2), queryRes.JSON200.ActiveVersion) assert.Equal(t, int32(2), queryRes.JSON200.LatestVersion) assert.Equal(t, jcfg, *queryRes.JSON200.Config) diff --git a/test/queryService/exportservice_test.go b/test/queryService/exportservice_test.go deleted file mode 100644 index a425cb57..00000000 --- a/test/queryService/exportservice_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package endtoend - -import ( - "context" - "testing" - - "queryorchestration/internal/test" - queryservice "queryorchestration/pkg/queryService" - - "github.com/stretchr/testify/assert" -) - -func TestExportService(t *testing.T) { - ctx := context.Background() - - c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{ - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": "/i/am/here", - "QUERY_VERSION_SYNC_URL": "iamthere", - }, - }) - defer cleanup() - - client, err := queryservice.NewClientWithResponses(c.URI) - assert.NoError(t, err) - - idRes, err := client.TriggerExportWithResponse(ctx, "CLIENT_ID", queryservice.ExportTrigger{}) - assert.NoError(t, err) - assert.NotNil(t, idRes) -}