Merged in feature/docresult (pull request #105)

Document Result Endpoint

* testing

* cleantesting

* progress

* query

* lint

* readme

* dockerclient

* api

* passtest

* tests

* test
This commit is contained in:
Michael McGuinness
2025-03-17 18:14:15 +00:00
parent f7c41c4ef3
commit 555b6d420b
105 changed files with 3276 additions and 2484 deletions
+35 -4
View File
@@ -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)
}