Merged in feature/textExtractionsPart2 (pull request #193)

Continue finishing the parts of the text extraction plan

* add missing fields
This commit is contained in:
Jay Brown
2025-12-02 19:13:08 +00:00
parent c45e1dd427
commit 3bdc27f4de
21 changed files with 2392 additions and 215 deletions
+73
View File
@@ -111,6 +111,79 @@ func TestUpdateClient(t *testing.T) {
assert.Equal(t, "new_name", client.Name)
}
func TestListClients(t *testing.T) {
cfg := &ControllerConfig{}
test.CreateDB(t, cfg)
initializeTestConfig(t, cfg)
svc := createControllerServices(cfg)
cons := queryapi.NewControllers(svc, cfg)
// Create multiple clients
clients := []struct {
id string
name string
}{
{"client_a", "Alpha Client"},
{"client_b", "Beta Client"},
{"client_c", "Charlie Client"},
}
for _, c := range clients {
err := cfg.GetDBQueries().CreateClient(t.Context(), &repository.CreateClientParams{
Clientid: c.id,
Name: c.name,
})
require.NoError(t, err)
err = cfg.GetDBQueries().AddClientCanSync(t.Context(), &repository.AddClientCanSyncParams{
Clientid: c.id,
Cansync: true,
})
require.NoError(t, err)
}
ctx, rec := createContext(t)
err := cons.ListClients(ctx)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, rec.Code)
var response queryapi.ClientListResponse
err = json.Unmarshal(rec.Body.Bytes(), &response)
require.NoError(t, err)
// Verify response
assert.Equal(t, int32(3), response.TotalCount)
assert.Len(t, response.Clients, 3)
// Verify clients are ordered by name (Alpha, Beta, Charlie)
assert.Equal(t, "Alpha Client", response.Clients[0].Name)
assert.Equal(t, "Beta Client", response.Clients[1].Name)
assert.Equal(t, "Charlie Client", response.Clients[2].Name)
}
func TestListClientsEmpty(t *testing.T) {
cfg := &ControllerConfig{}
test.CreateDB(t, cfg)
initializeTestConfig(t, cfg)
svc := createControllerServices(cfg)
cons := queryapi.NewControllers(svc, cfg)
ctx, rec := createContext(t)
err := cons.ListClients(ctx)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, rec.Code)
var response queryapi.ClientListResponse
err = json.Unmarshal(rec.Body.Bytes(), &response)
require.NoError(t, err)
assert.Equal(t, int32(0), response.TotalCount)
assert.Empty(t, response.Clients)
}
func initializeTestConfig(t testing.TB, cfg *ControllerConfig) {
// Reset the singleton config state for testing
serviceconfig.ResetConfigInitOnceTestOnly()