Skip to content

Commit

Permalink
Improve the test coverage (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd authored Aug 6, 2024
1 parent 5ac8c51 commit 424cd85
Show file tree
Hide file tree
Showing 49 changed files with 571 additions and 573 deletions.
1 change: 0 additions & 1 deletion cmd/dry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func dryCmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Failed to load config: %v", err)
}
initLogger := logger.NewLogger(logger.NewLoggerArgs{
Expand Down
1 change: 0 additions & 1 deletion cmd/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func schedulerCmd() *cobra.Command {
Run: func(cmd *cobra.Command, _ []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Configuration load failed: %v", err)
}
logger := logger.NewLogger(logger.NewLoggerArgs{
Expand Down
2 changes: 0 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func serverCmd() *cobra.Command {
Run: func(cmd *cobra.Command, _ []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Configuration load failed: %v", err)
}
logger := logger.NewLogger(logger.NewLoggerArgs{
Expand All @@ -53,7 +52,6 @@ func serverCmd() *cobra.Command {
cli := newClient(cfg, dataStore, logger)
server := frontend.New(cfg, logger, cli)
if err := server.Serve(cmd.Context()); err != nil {
// nolint
logger.Error("Server initialization failed", "error", err)
os.Exit(1)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func startCmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Configuration load failed: %v", err)
}

Expand Down
7 changes: 2 additions & 5 deletions cmd/start_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import (

func startAllCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "start-all",
// nolint
Use: "start-all",
Short: "Launches both the Dagu web UI server and the scheduler process.",
// nolint
Long: `dagu start-all [--dags=<DAGs dir>] [--host=<host>] [--port=<port>]`,
Long: `dagu start-all [--dags=<DAGs dir>] [--host=<host>] [--port=<port>]`,
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag("port", cmd.Flags().Lookup("port"))
_ = viper.BindPFlag("host", cmd.Flags().Lookup("host"))
Expand All @@ -42,7 +40,6 @@ func startAllCmd() *cobra.Command {
Run: func(cmd *cobra.Command, _ []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Configuration load failed: %v", err)
}
logger := logger.NewLogger(logger.NewLoggerArgs{
Expand Down
3 changes: 0 additions & 3 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func statusCmd() *cobra.Command {
Run: func(_ *cobra.Command, args []string) {
cfg, err := config.Load()
if err != nil {
// nolint
log.Fatalf("Configuration load failed: %v", err)
}
logger := logger.NewLogger(logger.NewLoggerArgs{
Expand All @@ -45,7 +44,6 @@ func statusCmd() *cobra.Command {
// Load the DAG file and get the current running status.
workflow, err := dag.Load(cfg.BaseConfig, args[0], "")
if err != nil {
// nolint
logger.Error("Workflow load failed", "error", err, "file", args[0])
os.Exit(1)
}
Expand All @@ -56,7 +54,6 @@ func statusCmd() *cobra.Command {
curStatus, err := cli.GetCurrentStatus(workflow)

if err != nil {
// nolint
logger.Error("Current status retrieval failed", "error", err)
os.Exit(1)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func versionCmd() *cobra.Command {
Short: "Display the binary version",
Long: `dagu version`,
Run: func(_ *cobra.Command, _ []string) {
// nolint // forbidgo
println(constants.Version)
},
}
Expand Down
11 changes: 11 additions & 0 deletions examples/foreach.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: foreach
foreach: "[1, 2, 3]"
command: sh
output: "foreach-$1.txt"
script: |
echo "Hello, world! $1"
- name: merge
command: sh
script: |
cat foreach-*.txt
1 change: 0 additions & 1 deletion internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func TestClient_GetStatus(t *testing.T) {
})
}

// nolint // paralleltest
func TestClient_RunDAG(t *testing.T) {
t.Run("RunDAG", func(t *testing.T) {
setup := test.SetupTest(t)
Expand Down
4 changes: 1 addition & 3 deletions internal/dag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ var (
errStepCommandMustBeArrayOrString = errors.New(
"step command must be an array of strings or a string",
)
errInvalidParamValue = errors.New("invalid parameter value")
errCallFunctionNotFound = errors.New(
"call must specify a functions that exists",
)
errNumberOfParamsMismatch = errors.New(
// nolint
"the number of parameters defined in the function does not match the number of parameters given",
)
errRequiredParameterNotFound = errors.New(
Expand Down Expand Up @@ -362,7 +362,6 @@ func (b *builder) buildMiscs() (err error) {
// Case 2: env is an array of maps.
// Case 3: is recommended because the order of the environment variables is
// preserved.
// nolint // cognitive complexity
func loadVariables(strVariables any, opts buildOpts) (
map[string]string, error,
) {
Expand Down Expand Up @@ -471,7 +470,6 @@ type stepBuilder struct {
}

// buildStep builds a step from the step definition.
// nolint // cognitive complexity
func (b *stepBuilder) buildStep(
variables []string, def *stepDef, fns []*funcDef,
) (*Step, error) {
Expand Down
Loading

0 comments on commit 424cd85

Please sign in to comment.