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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ jobs:

- name: Run tests with coverage
run: |
# Run tests on all packages with race detection
go test -v -race ./...
# Run tests on all packages with race detection and parallel execution
go test -v -race -parallel 8 ./...
# Calculate coverage only for pkg/ (cmd/ is CLI code with lower test coverage)
# Use -count=1 to disable test caching and get accurate coverage
go test -count=1 -coverprofile=coverage.out -covermode=atomic ./pkg/...
# Use -parallel 8 for faster execution (4.7x faster than sequential)
go test -count=1 -parallel 8 -coverprofile=coverage.out -covermode=atomic ./pkg/...
go tool cover -html=coverage.out -o coverage.html

- name: Calculate coverage
Expand Down
4 changes: 2 additions & 2 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ SCOPES REQUESTED:
• Cases and usage data

See: pup auth --help for complete scope list`,
RunE: runAuthLogin,
RunE: runAuthLogin,
}

var authStatusCmd = &cobra.Command{
Expand Down Expand Up @@ -266,7 +266,7 @@ REFRESH TOKEN:
The refresh token (valid for 30 days) is used to obtain new access tokens
without requiring a new browser login. If the refresh token expires, you'll
need to run 'pup auth login' again.`,
RunE: runAuthStatus,
RunE: runAuthStatus,
}

var authLogoutCmd = &cobra.Command{
Expand Down
8 changes: 4 additions & 4 deletions cmd/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ func TestCloudAzureCmd(t *testing.T) {

func TestCloudCmd_CommandHierarchy(t *testing.T) {
tests := []struct {
name string
parentCmd *cobra.Command
parentUse string
subcommandUse string
name string
parentCmd *cobra.Command
parentUse string
subcommandUse string
}{
{
name: "AWS subcommand",
Expand Down
6 changes: 3 additions & 3 deletions cmd/dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ FILTERING:

SORTING:
Dashboards are returned sorted by popularity (most viewed first).`,
RunE: runDashboardsList,
RunE: runDashboardsList,
}

var dashboardsGetCmd = &cobra.Command{
Expand Down Expand Up @@ -179,8 +179,8 @@ USE CASES:
• Version control dashboard definitions
• Programmatic dashboard generation
• Extract widget configurations for reuse`,
Args: cobra.ExactArgs(1),
RunE: runDashboardsGet,
Args: cobra.ExactArgs(1),
RunE: runDashboardsGet,
}

var dashboardsDeleteCmd = &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions cmd/dashboards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ func TestRunDashboardsGet(t *testing.T) {
defer cleanup()

tests := []struct {
name string
dashboardID string
wantErr bool
name string
dashboardID string
wantErr bool
}{
{
name: "with valid dashboard ID",
Expand Down
2 changes: 0 additions & 2 deletions cmd/error_tracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,3 @@ func TestErrorTrackingCmd_CommandHierarchy(t *testing.T) {
}
}
}


2 changes: 1 addition & 1 deletion cmd/incidents.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ FILTERING:

SORTING:
Incidents are returned sorted by creation time (most recent first).`,
RunE: runIncidentsList,
RunE: runIncidentsList,
}

var incidentsGetCmd = &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions cmd/incidents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func TestRunIncidentsGet(t *testing.T) {
defer cleanup()

tests := []struct {
name string
incidentID string
wantErr bool
name string
incidentID string
wantErr bool
}{
{
name: "with valid incident ID",
Expand Down
8 changes: 4 additions & 4 deletions cmd/integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ func TestIntegrationsWebhooksCmd(t *testing.T) {

func TestIntegrationsCmd_CommandHierarchy(t *testing.T) {
tests := []struct {
name string
parentCmd *cobra.Command
parentUse string
subcommandUse string
name string
parentCmd *cobra.Command
parentUse string
subcommandUse string
}{
{
name: "Slack subcommand",
Expand Down
1 change: 0 additions & 1 deletion cmd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,4 +959,3 @@ func runMetricsTagsList(cmd *cobra.Command, args []string) error {
// NOTE: ListTagsByMetricName is not available in datadog-api-client-go v2.30.0
return fmt.Errorf("listing tags by metric name is not supported in the current API client version")
}

100 changes: 50 additions & 50 deletions cmd/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ func TestRunMetricsSearch(t *testing.T) {
defer cleanup()

tests := []struct {
name string
query string
from string
to string
wantErr bool
name string
query string
from string
to string
wantErr bool
wantErrContains string
}{
{
name: "fails on client creation",
query: "avg:system.cpu.user{*}",
from: "1h",
to: "now",
wantErr: true,
name: "fails on client creation",
query: "avg:system.cpu.user{*}",
from: "1h",
to: "now",
wantErr: true,
wantErrContains: "mock client",
},
}
Expand Down Expand Up @@ -110,19 +110,19 @@ func TestRunMetricsQuery(t *testing.T) {
defer cleanup()

tests := []struct {
name string
query string
from string
to string
wantErr bool
name string
query string
from string
to string
wantErr bool
wantErrContains string
}{
{
name: "fails on client creation",
query: "avg:system.cpu.user{*}",
from: "1h",
to: "now",
wantErr: true,
name: "fails on client creation",
query: "avg:system.cpu.user{*}",
from: "1h",
to: "now",
wantErr: true,
wantErrContains: "mock client",
},
}
Expand Down Expand Up @@ -474,15 +474,15 @@ func TestRunMetricsMetadataGet(t *testing.T) {
defer cleanup()

tests := []struct {
name string
metricName string
wantErr bool
name string
metricName string
wantErr bool
wantErrContains string
}{
{
name: "fails on client creation",
metricName: "system.cpu.user",
wantErr: true,
name: "fails on client creation",
metricName: "system.cpu.user",
wantErr: true,
wantErrContains: "mock client",
},
}
Expand Down Expand Up @@ -511,39 +511,39 @@ func TestRunMetricsMetadataUpdate(t *testing.T) {
defer cleanup()

tests := []struct {
name string
metricName string
description string
unit string
metricType string
wantErr bool
name string
metricName string
description string
unit string
metricType string
wantErr bool
wantErrContains string
}{
{
name: "update description",
metricName: "system.cpu.user",
description: "CPU user time",
unit: "",
metricType: "",
wantErr: true,
name: "update description",
metricName: "system.cpu.user",
description: "CPU user time",
unit: "",
metricType: "",
wantErr: true,
wantErrContains: "mock client",
},
{
name: "update multiple fields",
metricName: "system.cpu.user",
description: "CPU user time",
unit: "percent",
metricType: "gauge",
wantErr: true,
name: "update multiple fields",
metricName: "system.cpu.user",
description: "CPU user time",
unit: "percent",
metricType: "gauge",
wantErr: true,
wantErrContains: "mock client",
},
{
name: "no fields specified hits client error first",
metricName: "system.cpu.user",
description: "",
unit: "",
metricType: "",
wantErr: true,
name: "no fields specified hits client error first",
metricName: "system.cpu.user",
description: "",
unit: "",
metricType: "",
wantErr: true,
wantErrContains: "mock client",
},
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ func TestMiscStatusCmd(t *testing.T) {

func TestMiscCmd_CommandStructure(t *testing.T) {
tests := []struct {
name string
cmd *cobra.Command
wantUse string
wantShort bool
wantRunE bool
wantArgs bool
name string
cmd *cobra.Command
wantUse string
wantShort bool
wantRunE bool
wantArgs bool
}{
{
name: "ip-ranges command",
Expand Down
2 changes: 1 addition & 1 deletion cmd/miscellaneous.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func runMiscIPRanges(cmd *cobra.Command, args []string) error {

func runMiscStatus(cmd *cobra.Command, args []string) error {
result := map[string]interface{}{
"status": "ok",
"status": "ok",
"message": "API is operational",
}

Expand Down
14 changes: 7 additions & 7 deletions cmd/monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ EXAMPLES:
}

var (
monitorName string
monitorTags string
monitorLimit int32
searchQuery string
searchPage int64
searchPerPage int64
searchSort string
monitorName string
monitorTags string
monitorLimit int32
searchQuery string
searchPage int64
searchPerPage int64
searchSort string
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
autoApprove bool

// Dependency injection points for testing
clientFactory = defaultClientFactory
clientFactory = defaultClientFactory
outputWriter io.Writer = os.Stdout
inputReader io.Reader = os.Stdin
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func TestFormatAPIError_AllStatusCodes(t *testing.T) {
{502, true, "Datadog API is experiencing issues"},
{503, true, "Datadog API is experiencing issues"},
{504, true, "Datadog API is experiencing issues"},
{200, false, ""}, // Should just show basic error
{201, false, ""}, // Should just show basic error
{200, false, ""}, // Should just show basic error
{201, false, ""}, // Should just show basic error
{418, true, "Invalid request"}, // Other 4xx
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/slos.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ FILTERING:
• Breaching SLOs: pup slos list | jq '.data[] | select(.status.state == "breaching")'
• High error budget: pup slos list | jq '.data[] | select(.status.error_budget_remaining > 50)'
• By tag: pup slos list | jq '.data[] | select(.tags[] | contains("team:backend"))'`,
RunE: runSlosList,
RunE: runSlosList,
}

var slosGetCmd = &cobra.Command{
Expand Down Expand Up @@ -197,8 +197,8 @@ USE CASES:
• Analyze historical SLO performance
• Track error budget burn rate
• Report on service reliability`,
Args: cobra.ExactArgs(1),
RunE: runSlosGet,
Args: cobra.ExactArgs(1),
RunE: runSlosGet,
}

var slosDeleteCmd = &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/callback/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

// CallbackResult represents the result of the OAuth callback
type CallbackResult struct {
Code string
State string
Error string
Code string
State string
Error string
ErrorDescription string
}

Expand Down
Loading