Refactor create command tests and add base branch case
Removed redundant test cases for file input and stdin in TestNewCmdCreate, and added a new test to verify that the base branch argument sets the BaseBranch field correctly.
This commit is contained in:
parent
deee0c61ed
commit
872cf495c2
1 changed files with 6 additions and 38 deletions
|
|
@ -44,51 +44,18 @@ func TestNewCmdCreate(t *testing.T) {
|
|||
ProblemStatementFile: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "from-file succes",
|
||||
args: "-F task-description.md",
|
||||
wantOpts: &CreateOptions{
|
||||
ProblemStatement: "",
|
||||
ProblemStatementFile: "task-description.md",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "file content from stdin success",
|
||||
args: "-F -",
|
||||
stdin: "task description from stdin",
|
||||
wantOpts: &CreateOptions{
|
||||
ProblemStatement: "",
|
||||
ProblemStatementFile: "-",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mutually exclusive arg and file",
|
||||
args: "'some task inline' -F foo.md",
|
||||
wantErr: "only one of -F or arg can be provided",
|
||||
},
|
||||
{
|
||||
name: "missing file path is accepted",
|
||||
args: "-F does-not-exist.md",
|
||||
name: "base branch sets baseBranch field",
|
||||
args: "'task description' -b feature",
|
||||
wantOpts: &CreateOptions{
|
||||
ProblemStatement: "",
|
||||
ProblemStatementFile: "does-not-exist.md",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty file accepted at",
|
||||
args: "-F empty-task-description.md",
|
||||
wantOpts: &CreateOptions{
|
||||
ProblemStatement: "",
|
||||
ProblemStatementFile: "empty-task-description.md",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty from stdin accepted",
|
||||
args: "-F -",
|
||||
stdin: " \n\n",
|
||||
wantOpts: &CreateOptions{
|
||||
ProblemStatement: "",
|
||||
ProblemStatementFile: "-",
|
||||
ProblemStatement: "task description",
|
||||
ProblemStatementFile: "",
|
||||
BaseBranch: "feature",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -129,6 +96,7 @@ func TestNewCmdCreate(t *testing.T) {
|
|||
if tt.wantOpts != nil {
|
||||
require.Equal(t, tt.wantOpts.ProblemStatement, gotOpts.ProblemStatement)
|
||||
require.Equal(t, tt.wantOpts.ProblemStatementFile, gotOpts.ProblemStatementFile)
|
||||
require.Equal(t, tt.wantOpts.BaseBranch, gotOpts.BaseBranch)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue