feat(accounts): add provider account inventory api
This commit is contained in:
@@ -121,6 +121,9 @@ func (s *RuntimeImportService) Import(ctx context.Context, req RuntimeImportRequ
|
||||
if err := s.store.ImportBatches().UpdateStatus(ctx, batchID, report.BatchStatus, report.AccessStatus); err != nil {
|
||||
return RuntimeImportResult{}, err
|
||||
}
|
||||
if err := sqlite.SyncProviderAccountsFromImportBatch(ctx, s.store, batchID); err != nil {
|
||||
return RuntimeImportResult{}, err
|
||||
}
|
||||
if importErr != nil {
|
||||
return RuntimeImportResult{BatchID: batchID, Report: report}, importErr
|
||||
}
|
||||
|
||||
@@ -87,6 +87,9 @@ func TestRuntimeImportServicePersistsOperationalState(t *testing.T) {
|
||||
if got := queryCount(t, store.SQLDB(), "access_closure_records"); got != 1 {
|
||||
t.Fatalf("access_closure_records row count = %d, want 1", got)
|
||||
}
|
||||
if got := queryCount(t, store.SQLDB(), "provider_accounts"); got != 2 {
|
||||
t.Fatalf("provider_accounts row count = %d, want 2", got)
|
||||
}
|
||||
|
||||
var batchStatus string
|
||||
var accessStatus string
|
||||
@@ -111,6 +114,18 @@ func TestRuntimeImportServicePersistsOperationalState(t *testing.T) {
|
||||
if accountStatus != "passed" {
|
||||
t.Fatalf("account_status = %q, want passed", accountStatus)
|
||||
}
|
||||
|
||||
var inventoryStatus string
|
||||
var inventoryShadowGroup string
|
||||
if err := store.SQLDB().QueryRowContext(context.Background(), "SELECT account_status, shadow_group_id FROM provider_accounts WHERE host_account_id = ? ORDER BY id LIMIT 1", "account_1").Scan(&inventoryStatus, &inventoryShadowGroup); err != nil {
|
||||
t.Fatalf("query provider account inventory: %v", err)
|
||||
}
|
||||
if inventoryStatus != sqlite.ProviderAccountStatusActive {
|
||||
t.Fatalf("provider_accounts.account_status = %q, want %q", inventoryStatus, sqlite.ProviderAccountStatusActive)
|
||||
}
|
||||
if inventoryShadowGroup == "" {
|
||||
t.Fatal("provider_accounts.shadow_group_id = empty, want group id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeImportServiceIncludesMatchingHostOverlaysInReport(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user