Add branchless trail creation · Entire

Add branchless trail creation

9f09715·

dipree·3w ago·2 files·+125 added/-6 removed

Sessions

6604ab821878View transcript

Changes

2

875 unmodified lines

507 unmodified lines

875 unmodified lines

Mcmd/entire/cli/trail_cmd.go+8/-6

4 unmodified lines
// runTrailCreateInteractive runs the interactive form for trail creation.
// Prompts for title, body, branch (derived from title, unless branchless), and status.
func runTrailCreateInteractive(title, body, branch, statusStr *string, noBranch bool) error {

var runTrailCreateForm = func(form *huh.Form) error { return form.Run() }

return strings.Join(names, ", ")
}

func TestRunTrailCreateInteractiveBranchlessSkipsBranchPrompt(t *testing.T) {

t.Parallel(): runTrailCreateForm is package-global test seam.

var gotCreate map[string]any
var gotCreateAuth string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

switch {

case r.Method == http.MethodPost && r.URL.Path == "/oauth/token":
        w.Header().Set("Content-Type", "application/json")
        _, _ = fmt.Fprint(w, `{"access_token":"exchanged-token","token_type":"Bearer","expires_in":3600}`)

case r.Method == http.MethodPost && r.URL.Path == "/api/v1/trails/gh/acme/repo":
        gotCreateAuth = r.Header.Get("Authorization")

err := runTrailCreate(cmd, "Branchless full path", "body", "main", "", "", false, true)

require.NoError(t, err)
        require.Contains(t, gotCreateAuth, "Bearer ")
        require.Equal(t, "Branchless full path", gotCreate["title"])  
}