Skip to content

Commit

Permalink
Fix connection details test and refs to shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenwindflower committed Apr 14, 2024
1 parent c1c785e commit 6032a44
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 27 deletions.
3 changes: 2 additions & 1 deletion generate_column_desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"os"
"regexp"
"sync"
"tbd/shared"
"time"

"github.com/gwenwindflower/tbd/shared"
)

type Payload struct {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"log"
"sync"
"tbd/sourcerer"
"time"

"github.com/charmbracelet/huh/spinner"
"github.com/gwenwindflower/tbd/sourcerer"
)

type Elapsed struct {
Expand Down
65 changes: 48 additions & 17 deletions set_connection_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package main

import (
"log"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"
)

func SetConnectionDetails(formResponse FormResponse) shared.ConnectionDetails {
Expand All @@ -12,24 +13,54 @@ func SetConnectionDetails(formResponse FormResponse) shared.ConnectionDetails {
if err != nil {
log.Fatalf("Could not get dbt profile %v\n", err)
}
connectionDetails = shared.ConnectionDetails{
ConnType: profile.Outputs[formResponse.DbtProfileOutput].ConnType,
Username: profile.Outputs[formResponse.DbtProfileOutput].User,
Account: profile.Outputs[formResponse.DbtProfileOutput].Account,
Schema: formResponse.Schema,
Database: profile.Outputs[formResponse.DbtProfileOutput].Database,
Project: profile.Outputs[formResponse.DbtProfileOutput].Project,
Dataset: formResponse.Schema,
switch profile.Outputs[formResponse.DbtProfileOutput].ConnType {
case "snowflake":
{
connectionDetails = shared.ConnectionDetails{
ConnType: profile.Outputs[formResponse.DbtProfileOutput].ConnType,
Username: profile.Outputs[formResponse.DbtProfileOutput].User,
Account: profile.Outputs[formResponse.DbtProfileOutput].Account,
Database: profile.Outputs[formResponse.DbtProfileOutput].Database,
Schema: formResponse.Schema,
}
}
case "bigquery":
{
connectionDetails = shared.ConnectionDetails{
ConnType: profile.Outputs[formResponse.DbtProfileOutput].ConnType,
Project: profile.Outputs[formResponse.DbtProfileOutput].Project,
Dataset: profile.Outputs[formResponse.DbtProfileOutput].Dataset,
}
}
default:
{
log.Fatalf("Unsupported connection type %v\n", profile.Outputs[formResponse.DbtProfileOutput].ConnType)
}
}
} else {
connectionDetails = shared.ConnectionDetails{
ConnType: formResponse.Warehouse,
Username: formResponse.Username,
Account: formResponse.Account,
Schema: formResponse.Schema,
Database: formResponse.Database,
Project: formResponse.Project,
Dataset: formResponse.Dataset,
switch formResponse.Warehouse {
case "snowflake":
{
connectionDetails = shared.ConnectionDetails{
ConnType: formResponse.Warehouse,
Username: formResponse.Username,
Account: formResponse.Account,
Schema: formResponse.Schema,
Database: formResponse.Database,
}
}
case "bigquery":
{
connectionDetails = shared.ConnectionDetails{
ConnType: formResponse.Warehouse,
Project: formResponse.Project,
Dataset: formResponse.Dataset,
}
}
default:
{
log.Fatalf("Unsupported connection type %v\n", formResponse.Warehouse)
}
}
}
return connectionDetails
Expand Down
4 changes: 3 additions & 1 deletion set_connection_details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"os"
"tbd/shared"
"testing"

"github.com/gwenwindflower/tbd/shared"
)

func TestSetConnectionDetailsWithoutDbtProfile(t *testing.T) {
Expand Down Expand Up @@ -39,6 +40,7 @@ func TestSetConnectionDetailsWithDbtProfile(t *testing.T) {
UseDbtProfile: true,
DbtProfile: "elf",
DbtProfileOutput: "dev",
Schema: "hall_of_thranduil",
GenerateDescriptions: false,
BuildDir: "test_build",
Confirm: true,
Expand Down
3 changes: 2 additions & 1 deletion sourcerer/get_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"context"
"fmt"
"log"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"

"cloud.google.com/go/bigquery"
"google.golang.org/api/iterator"
Expand Down
3 changes: 2 additions & 1 deletion sourcerer/get_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"database/sql"
"errors"
"strings"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"

"cloud.google.com/go/bigquery"
)
Expand Down
3 changes: 2 additions & 1 deletion sourcerer/get_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"context"
"fmt"
"log"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"

"google.golang.org/api/iterator"
)
Expand Down
3 changes: 2 additions & 1 deletion sourcerer/put_columns_on_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"log"
"regexp"
"sync"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"
)

func (sfc *SfConn) PutColumnsOnTables(ctx context.Context, tables shared.SourceTables) {
Expand Down
3 changes: 2 additions & 1 deletion write_staging_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"os"
"strings"
"sync"
"tbd/shared"
"text/template"

"github.com/gwenwindflower/tbd/shared"
)

//go:embed *.sql
Expand Down
3 changes: 2 additions & 1 deletion write_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package main
import (
"log"
"os"
"tbd/shared"

"github.com/gwenwindflower/tbd/shared"

"gopkg.in/yaml.v2"
)
Expand Down
3 changes: 2 additions & 1 deletion write_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"os"
"tbd/shared"
"testing"

"github.com/gwenwindflower/tbd/shared"
)

func TestWriteYAML(t *testing.T) {
Expand Down

0 comments on commit 6032a44

Please sign in to comment.