Skip to content

Commit

Permalink
Merge pull request #443 from bruin-data/feature/support-empty-run-path
Browse files Browse the repository at this point in the history
support empty run path
  • Loading branch information
karakanb authored Feb 4, 2025
2 parents d3de2d6 + 3ba2f76 commit 3ea879d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func ParseDate(startDateStr, endDateStr string, logger *zap.SugaredLogger) (time

func ValidateRunConfig(runConfig *scheduler.RunConfig, inputPath string, logger *zap.SugaredLogger) (time.Time, time.Time, string, error) {
if inputPath == "" {
return time.Now(), time.Now(), "", errors.New("please give a task or pipeline path: bruin run <path to the task definition>)")
inputPath = "."
}

startDate, endDate, err := ParseDate(runConfig.StartDate, runConfig.EndDate, logger)
Expand Down
35 changes: 20 additions & 15 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,19 +1071,13 @@ func TestValidation(t *testing.T) {
logger := zaptest.NewLogger(t).Sugar()

tests := []struct {
name string
runConfig *scheduler.RunConfig
inputPath string
expectError bool
expectedError string
name string
runConfig *scheduler.RunConfig
inputPath string
expectedInputPath string
expectError bool
expectedError string
}{
{
name: "Empty Input Path",
runConfig: &scheduler.RunConfig{},
inputPath: "",
expectError: true,
expectedError: "please give a task or pipeline path: bruin run <path to the task definition>)",
},
{
name: "Invalid Start Date",
runConfig: &scheduler.RunConfig{
Expand All @@ -1108,8 +1102,19 @@ func TestValidation(t *testing.T) {
StartDate: "2023-12-01",
EndDate: "2023-12-31",
},
inputPath: "some/path",
expectError: false,
inputPath: "some/path",
expectedInputPath: "some/path",
expectError: false,
},
{
name: "valid input without a path, should default to the current path",
runConfig: &scheduler.RunConfig{
StartDate: "2023-12-01",
EndDate: "2023-12-31",
},
inputPath: "",
expectedInputPath: ".",
expectError: false,
},
}

Expand All @@ -1127,7 +1132,7 @@ func TestValidation(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, time.Date(2023, 12, 1, 0, 0, 0, 0, time.UTC), startDate)
assert.Equal(t, time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC), endDate)
assert.Equal(t, tt.inputPath, path)
assert.Equal(t, tt.expectedInputPath, path)
}
})
}
Expand Down

0 comments on commit 3ea879d

Please sign in to comment.