-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor test command to add a test (#186)
- Loading branch information
1 parent
b6b8090
commit 90d144b
Showing
7 changed files
with
193 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ tmp | |
testdata/caches | ||
cache | ||
out.yaml | ||
dependabot | ||
./dependabot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/dependabot/cli/internal/infra" | ||
"testing" | ||
) | ||
|
||
func TestTestCommand(t *testing.T) { | ||
t.Cleanup(func() { | ||
executeTestJob = infra.Run | ||
}) | ||
|
||
t.Run("Read a scenario file", func(t *testing.T) { | ||
var actualParams *infra.RunParams | ||
executeTestJob = func(params infra.RunParams) error { | ||
actualParams = ¶ms | ||
return nil | ||
} | ||
cmd := NewTestCommand() | ||
err := cmd.ParseFlags([]string{"-f", "../../../../testdata/scenario.yml"}) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
err = cmd.RunE(cmd, nil) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
if actualParams == nil { | ||
t.Fatalf("expected params to be set") | ||
} | ||
if actualParams.InputName == "" { | ||
t.Errorf("expected input name to be set") | ||
} | ||
if actualParams.Job.PackageManager != "go_modules" { | ||
t.Errorf("expected package manager to be set") | ||
} | ||
}) | ||
} |
Oops, something went wrong.