Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/dbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func formatErr(err error) string {
case errors.Is(err, auth.ErrNoTrialLicense):
return errStyle.Render("Could not download license, trial not started")
case errors.Is(err, dbc.ErrUnauthorized):
return errStyle.Render(err.Error())
return errStyle.Render(err.Error()) + "\n" +
msgStyle.Render("Did you run `dbc auth login`?")
case errors.Is(err, dbc.ErrUnauthorizedColumnar):
Comment on lines +156 to 158
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msgStyle is defined in cmd/dbc/add.go but is now also used by cmd/dbc/main.go. To avoid hidden cross-file coupling (and make styles easier to discover), consider moving msgStyle (and possibly errStyle) into a dedicated shared file (e.g., cmd/dbc/styles.go) in the main package.

Copilot uses AI. Check for mistakes.
return errStyle.Render(err.Error()) + "\n" +
msgStyle.Render("Installing this driver requires a license. Verify you have an active license at https://console.columnar.tech/licenses and try this command again. Contact support@columnar.tech if you believe this is an error.")
Expand Down
42 changes: 42 additions & 0 deletions cmd/dbc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,55 @@ package main
import (
"bytes"
"context"
"fmt"
"strings"
"testing"
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/columnar-tech/dbc"
"github.com/stretchr/testify/require"
)

func TestFormatErr(t *testing.T) {
tests := []struct {
name string
err error
wantSubstring []string
}{
{
name: "ErrUnauthorized direct",
err: dbc.ErrUnauthorized,
wantSubstring: []string{dbc.ErrUnauthorized.Error(), "Did you run `dbc auth login`?"},
},
{
name: "ErrUnauthorized wrapped",
err: fmt.Errorf("operation failed: %w", dbc.ErrUnauthorized),
wantSubstring: []string{dbc.ErrUnauthorized.Error(), "Did you run `dbc auth login`?"},
},
{
name: "ErrUnauthorizedColumnar direct",
err: dbc.ErrUnauthorizedColumnar,
wantSubstring: []string{dbc.ErrUnauthorizedColumnar.Error(), "active license", "support@columnar.tech"},
},
{
name: "ErrUnauthorizedColumnar wrapped",
err: fmt.Errorf("operation failed: %w", dbc.ErrUnauthorizedColumnar),
wantSubstring: []string{dbc.ErrUnauthorizedColumnar.Error(), "active license", "support@columnar.tech"},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := formatErr(tt.err)
for _, want := range tt.wantSubstring {
require.True(t, strings.Contains(got, want),
"formatErr(%v) = %q, expected to contain %q", tt.err, got, want)
}
})
}
}

func TestCmdStatus(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading