simplify the logic a bit and add suggestions to repl and cli
This commit is contained in:
@@ -25,6 +25,7 @@ type DependencyManagementTask struct {
|
|||||||
done bool
|
done bool
|
||||||
app *App
|
app *App
|
||||||
setupIssue *Issue
|
setupIssue *Issue
|
||||||
|
depIssues []*Issue
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDependencyManagementTask(app *App) *DependencyManagementTask {
|
func NewDependencyManagementTask(app *App) *DependencyManagementTask {
|
||||||
@@ -62,7 +63,7 @@ func (t *DependencyManagementTask) Setup(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
depIssues := []*Issue{
|
t.depIssues = []*Issue{
|
||||||
NewIssueBuilder().
|
NewIssueBuilder().
|
||||||
WithTitle("Setup database connection").
|
WithTitle("Setup database connection").
|
||||||
WithDescription("Configure database connection pool.").
|
WithDescription("Configure database connection pool.").
|
||||||
@@ -70,6 +71,13 @@ func (t *DependencyManagementTask) Setup(ctx context.Context) error {
|
|||||||
WithStatus(models.StatusOpen).
|
WithStatus(models.StatusOpen).
|
||||||
WithIssueType(models.TypeTask).
|
WithIssueType(models.TypeTask).
|
||||||
Build(),
|
Build(),
|
||||||
|
NewIssueBuilder().
|
||||||
|
WithTitle("Create home page for the website").
|
||||||
|
WithDescription("Create a page for the website.").
|
||||||
|
WithPriority(2).
|
||||||
|
WithStatus(models.StatusOpen).
|
||||||
|
WithIssueType(models.TypeTask).
|
||||||
|
Build(),
|
||||||
NewIssueBuilder().
|
NewIssueBuilder().
|
||||||
WithTitle("Implement Authentication System").
|
WithTitle("Implement Authentication System").
|
||||||
WithDescription("Add login/logout functionality. Depends on 'Setup database connection' issue.").
|
WithDescription("Add login/logout functionality. Depends on 'Setup database connection' issue.").
|
||||||
@@ -84,13 +92,6 @@ func (t *DependencyManagementTask) Setup(ctx context.Context) error {
|
|||||||
WithStatus(models.StatusOpen).
|
WithStatus(models.StatusOpen).
|
||||||
WithIssueType(models.TypeTask).
|
WithIssueType(models.TypeTask).
|
||||||
Build(),
|
Build(),
|
||||||
NewIssueBuilder().
|
|
||||||
WithTitle("Create home page for the website").
|
|
||||||
WithDescription("Create a page for the website.").
|
|
||||||
WithPriority(2).
|
|
||||||
WithStatus(models.StatusOpen).
|
|
||||||
WithIssueType(models.TypeTask).
|
|
||||||
Build(),
|
|
||||||
NewIssueBuilder().
|
NewIssueBuilder().
|
||||||
WithTitle("Create user profile page").
|
WithTitle("Create user profile page").
|
||||||
WithDescription("Frontend user profile page. Depends on 'Create home page for the website' issue.").
|
WithDescription("Frontend user profile page. Depends on 'Create home page for the website' issue.").
|
||||||
@@ -107,7 +108,7 @@ func (t *DependencyManagementTask) Setup(ctx context.Context) error {
|
|||||||
Build(),
|
Build(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.app.Issues.CreateIssues(ctx, depIssues, ""); err != nil {
|
if err := t.app.Issues.CreateIssues(ctx, t.depIssues, ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,46 +126,36 @@ func (t *DependencyManagementTask) Validate(ctx context.Context) ValidationFeedb
|
|||||||
taskIssue := t.setupIssue
|
taskIssue := t.setupIssue
|
||||||
issues, err := FetchIssues(ctx, t.app, t.setupIssue)
|
issues, err := FetchIssues(ctx, t.app, t.setupIssue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return expect.ValidationFeedback
|
return expect.Fatal("Could not fetch issues")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for _, issue := range issues {
|
for _, issue := range issues {
|
||||||
if issue.Title == "Implement Authentication System" || issue.Title == "Add user management operations" || issue.Title == "Create user profile page" || issue.Title == "Create about page" {
|
for _, depIssue := range t.depIssues[2:] {
|
||||||
|
if issue.Title == depIssue.Title {
|
||||||
expect.Equal(issue.Status, models.StatusBlocked,
|
expect.Equal(issue.Status, models.StatusBlocked,
|
||||||
fmt.Sprintf("%s status", issue.Title))
|
fmt.Sprintf("%s status", issue.Title))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if expect.Errors() != nil {
|
for _, foundationalIssue := range t.depIssues[:2] {
|
||||||
return expect.ValidationFeedback
|
if issue.Title == foundationalIssue.Title {
|
||||||
}
|
|
||||||
|
|
||||||
for _, issue := range issues {
|
|
||||||
if issue.Title == "Setup database connection" || issue.Title == "Create home page for the website" {
|
|
||||||
expect.Equal(issue.Priority, 3,
|
expect.Equal(issue.Priority, 3,
|
||||||
fmt.Sprintf("Priority of '%s' should be 3 (high)", issue.Title))
|
fmt.Sprintf("%s priority", issue.Title))
|
||||||
expect.Equal(issue.Assignee, "Me",
|
expect.Equal(issue.Assignee, "Me",
|
||||||
fmt.Sprintf("Assignee of '%s' should be 'Me'", issue.Title))
|
fmt.Sprintf("%s assignee", issue.Title))
|
||||||
expect.Equal(issue.Status, models.StatusInProgress,
|
expect.Equal(issue.Status, models.StatusInProgress,
|
||||||
fmt.Sprintf("Status of '%s' should be In Progress", issue.Title))
|
fmt.Sprintf("%s status", issue.Title))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if expect.Errors() != nil {
|
}
|
||||||
|
|
||||||
|
if !expect.Valid() {
|
||||||
return expect.ValidationFeedback
|
return expect.ValidationFeedback
|
||||||
}
|
}
|
||||||
|
|
||||||
expect.Assert(taskIssue.Status == models.StatusClosed,
|
expect.Equal(taskIssue.Status, models.StatusClosed,
|
||||||
fmt.Sprintf("'%s' should be set to closed", taskIssue.Title))
|
fmt.Sprintf("%s", taskIssue.Title))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return expect.Complete()
|
return expect.Complete()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
// Variables for completion options and functions.
|
// Variables for completion options and functions.
|
||||||
var (
|
var (
|
||||||
typeOptions = []string{"bug", "feature", "task", "chore"}
|
typeOptions = []string{"bug", "feature", "task", "chore"}
|
||||||
statusOptions = []string{"open", "closed", "in_progress", "ready_to_sprint"}
|
statusOptions = []string{"open", "closed", "in_progress", "blocked", "ready_to_sprint"}
|
||||||
priorityRange = []string{"0", "1", "2", "3", "4"}
|
priorityRange = []string{"0", "1", "2", "3", "4"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ var statusValues = []prompt.Suggest{
|
|||||||
{Text: "open", Description: "Open status"},
|
{Text: "open", Description: "Open status"},
|
||||||
{Text: "closed", Description: "Closed status"},
|
{Text: "closed", Description: "Closed status"},
|
||||||
{Text: "in_progress", Description: "In progress status"},
|
{Text: "in_progress", Description: "In progress status"},
|
||||||
|
{Text: "blocked", Description: "Blocked status"},
|
||||||
{Text: "ready_to_sprint", Description: "Ready to sprint status"},
|
{Text: "ready_to_sprint", Description: "Ready to sprint status"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user