@@ -12,7 +12,7 @@ afterAll(() => { delete process.env.ALTIMATE_TELEMETRY_DISABLED })
1212import * as Registry from "../../src/altimate/native/connections/registry"
1313import { detectAuthMethod } from "../../src/altimate/native/connections/registry"
1414import * as CredentialStore from "../../src/altimate/native/connections/credential-store"
15- import { parseDbtProfiles } from "../../src/altimate/native/connections/dbt-profiles"
15+ import { parseDbtProfiles , dbtConnectionsToConfigs } from "../../src/altimate/native/connections/dbt-profiles"
1616import { discoverContainers , containerToConfig } from "../../src/altimate/native/connections/docker-discovery"
1717import { registerAll } from "../../src/altimate/native/connections/register"
1818
@@ -534,6 +534,91 @@ warehouse_b:
534534 }
535535 } )
536536 // altimate_change end
537+
538+ test ( "spark adapter maps to databricks" , async ( ) => {
539+ const fs = await import ( "fs" )
540+ const os = await import ( "os" )
541+ const path = await import ( "path" )
542+
543+ const tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "dbt-test-" ) )
544+ const profilesPath = path . join ( tmpDir , "profiles.yml" )
545+
546+ fs . writeFileSync (
547+ profilesPath ,
548+ `
549+ spark_project:
550+ outputs:
551+ prod:
552+ type: spark
553+ server_hostname: my-spark-cluster.databricks.com
554+ http_path: /sql/1.0/warehouses/abc123
555+ token: dapi_secret
556+ ` ,
557+ )
558+
559+ try {
560+ const connections = await parseDbtProfiles ( profilesPath )
561+ expect ( connections ) . toHaveLength ( 1 )
562+ expect ( connections [ 0 ] . type ) . toBe ( "databricks" )
563+ expect ( connections [ 0 ] . config . type ) . toBe ( "databricks" )
564+ } finally {
565+ fs . rmSync ( tmpDir , { recursive : true } )
566+ }
567+ } )
568+
569+ test ( "trino adapter maps to postgres (wire-compatible)" , async ( ) => {
570+ const fs = await import ( "fs" )
571+ const os = await import ( "os" )
572+ const path = await import ( "path" )
573+
574+ const tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "dbt-test-" ) )
575+ const profilesPath = path . join ( tmpDir , "profiles.yml" )
576+
577+ fs . writeFileSync (
578+ profilesPath ,
579+ `
580+ trino_project:
581+ outputs:
582+ prod:
583+ type: trino
584+ host: trino.example.com
585+ port: 8080
586+ user: analyst
587+ dbname: hive
588+ ` ,
589+ )
590+
591+ try {
592+ const connections = await parseDbtProfiles ( profilesPath )
593+ expect ( connections ) . toHaveLength ( 1 )
594+ expect ( connections [ 0 ] . type ) . toBe ( "postgres" )
595+ expect ( connections [ 0 ] . config . type ) . toBe ( "postgres" )
596+ } finally {
597+ fs . rmSync ( tmpDir , { recursive : true } )
598+ }
599+ } )
600+ } )
601+
602+ // ---------------------------------------------------------------------------
603+ // dbtConnectionsToConfigs
604+ // ---------------------------------------------------------------------------
605+
606+ describe ( "dbtConnectionsToConfigs" , ( ) => {
607+ test ( "converts connection array to keyed record" , ( ) => {
608+ const connections = [
609+ { name : "pg_dev" , type : "postgres" , config : { type : "postgres" , host : "localhost" } } ,
610+ { name : "sf_prod" , type : "snowflake" , config : { type : "snowflake" , account : "abc" } } ,
611+ ]
612+ const result = dbtConnectionsToConfigs ( connections )
613+ expect ( Object . keys ( result ) ) . toHaveLength ( 2 )
614+ expect ( result [ "pg_dev" ] . type ) . toBe ( "postgres" )
615+ expect ( result [ "sf_prod" ] . type ) . toBe ( "snowflake" )
616+ } )
617+
618+ test ( "returns empty object for empty array" , ( ) => {
619+ const result = dbtConnectionsToConfigs ( [ ] )
620+ expect ( result ) . toEqual ( { } )
621+ } )
537622} )
538623
539624// ---------------------------------------------------------------------------
@@ -546,6 +631,28 @@ describe("Docker discovery", () => {
546631 expect ( containers ) . toEqual ( [ ] )
547632 } )
548633
634+ test ( "containerToConfig creates config with all fields from a fully-populated container" , ( ) => {
635+ const container = {
636+ container_id : "abc123def456" ,
637+ name : "my-postgres" ,
638+ image : "postgres:16" ,
639+ db_type : "postgres" ,
640+ host : "127.0.0.1" ,
641+ port : 5432 ,
642+ user : "admin" ,
643+ password : "secret" ,
644+ database : "mydb" ,
645+ status : "running" ,
646+ }
647+ const config = containerToConfig ( container as any )
648+ expect ( config . type ) . toBe ( "postgres" )
649+ expect ( config . host ) . toBe ( "127.0.0.1" )
650+ expect ( config . port ) . toBe ( 5432 )
651+ expect ( config . user ) . toBe ( "admin" )
652+ expect ( config . password ) . toBe ( "secret" )
653+ expect ( config . database ) . toBe ( "mydb" )
654+ } )
655+
549656 test ( "containerToConfig omits undefined optional fields" , ( ) => {
550657 const container = {
551658 container_id : "def456" ,
0 commit comments