Skip to content

Commit e542ecf

Browse files
committed
Merge remote-tracking branch 'origin/main' into zimeg-refactor-iostreams-prompts
# Conflicts: # internal/iostreams/survey.go
2 parents 2f729ee + f23e6d3 commit e542ecf

26 files changed

Lines changed: 410 additions & 680 deletions

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
default: "dev-build"
114114
docker: # run the steps with Docker
115115
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/
116-
- image: cimg/go:1.26.0
116+
- image: cimg/go:1.26.1
117117
steps: # steps that comprise the `build` job
118118
- checkout # check out source code to working directory
119119
- restore_cache: # restores saved cache if no changes are detected since last run

.claude/CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ func NewExampleCommand(clients *shared.ClientFactory) *cobra.Command {
135135
- Mock the `ClientFactory` and its dependencies for testing
136136
- Always mock file system operations using `afero.Fs` to enable testability
137137

138+
### Test Naming Conventions
139+
140+
Test function names use the format `Test_StructName_FunctionName` for methods on a struct, or `Test_FunctionName` for package-level functions:
141+
142+
```go
143+
func Test_Client_GetAppStatus(t *testing.T) { ... } // struct method
144+
func Test_getKeyLength(t *testing.T) { ... } // package-level function
145+
```
146+
147+
### Test Ordering Conventions
148+
149+
Constructor functions (`NewXYZ`) should always be declared first, at the top of the test file. After constructors, test functions should be ordered alphabetically within each file. When a file has logical sections (separated by comments), tests should be alphabetical within each section. Getter and setter functions are grouped together under the base name — ignore the `Get` or `Set` prefix when determining order (e.g. `Test_AppName` and `Test_SetAppName` both sort under `A`). Exceptions to alphabetical ordering can be made when it doesn't work well for readability or logical grouping.
150+
138151
### Table-Driven Test Conventions
139152

140153
**Preferred: Map pattern** - uses `tc` for test case variable:

.github/MAINTAINERS_GUIDE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,34 @@ The branch name can also be set by changing
383383
for the `build-lint-test-e2e-test` workflow in the `.circleci/config.yml` file,
384384
but take care not to merge this change into `main`!
385385
386+
#### Test naming conventions
387+
388+
Test function names should use the format `Test_StructName_FunctionName` for methods
389+
on a struct, or `Test_FunctionName` for package-level functions. The underscore after
390+
`Test` separates the Go test prefix from the identifier being tested:
391+
392+
```go
393+
// Testing a method on a struct
394+
func Test_Client_GetAppStatus(t *testing.T) { ... }
395+
396+
// Testing a package-level function
397+
func Test_getKeyLength(t *testing.T) { ... }
398+
```
399+
400+
#### Test ordering conventions
401+
402+
Constructor functions (`NewXYZ`) should always be declared first, at the top of the
403+
test file. After constructors, test functions should be ordered alphabetically. When
404+
a file has logical sections (separated by comments), tests should be alphabetical
405+
within each section.
406+
407+
Getter and setter functions should be grouped together under the base name. Ignore
408+
the `Get` or `Set` prefix when determining alphabetical order. For example,
409+
`Test_AppName` and `Test_SetAppName` are both sorted under `A` for `AppName`.
410+
411+
Exceptions to alphabetical ordering can be made when it doesn't work well for
412+
readability or logical grouping.
413+
386414
#### Contributing tests
387415

388416
If you'd like to add tests, please review our

.github/workflows/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
steps:
4646
- name: Gather credentials
4747
id: credentials
48-
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
48+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
4949
with:
5050
app-id: ${{ secrets.GH_APP_ID_RELEASER }}
5151
private-key: ${{ secrets.GH_APP_PRIVATE_KEY_RELEASER }}

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Go
2626
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
2727
with:
28-
go-version: "1.26.0"
28+
go-version: "1.26.1"
2929
- name: Lint
3030
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
3131
with:
@@ -57,7 +57,7 @@ jobs:
5757
- name: Set up Go
5858
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
5959
with:
60-
go-version: "1.26.0"
60+
go-version: "1.26.1"
6161
- name: Report health score
6262
uses: slackapi/slack-health-score@d58a419f15cdaff97e9aa7f09f95772830ab66f7 # v0.1.1
6363
with:

cmd/project/create_samples.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"sort"
2222
"strings"
2323

24+
"github.com/slackapi/slack-cli/internal/experiment"
2425
"github.com/slackapi/slack-cli/internal/iostreams"
2526
"github.com/slackapi/slack-cli/internal/pkg/create"
2627
"github.com/slackapi/slack-cli/internal/shared"
@@ -64,14 +65,26 @@ func promptSampleSelection(ctx context.Context, clients *shared.ClientFactory, s
6465
}
6566

6667
sortedRepos := sortRepos(filteredRepos)
67-
selectOptions := createSelectOptions(sortedRepos)
68+
selectOptions := make([]string, len(sortedRepos))
69+
for i, r := range sortedRepos {
70+
if !clients.Config.WithExperimentOn(experiment.Charm) {
71+
selectOptions[i] = fmt.Sprint(i+1, ". ", r.Name)
72+
} else {
73+
selectOptions[i] = r.Name
74+
}
75+
}
6876

6977
var selectedTemplate string
7078
selection, err = clients.IO.SelectPrompt(ctx, "Select a sample to build upon:", selectOptions, iostreams.SelectPromptConfig{
7179
Description: func(value string, index int) string {
72-
return sortedRepos[index].Description + "\n https://github.com/" + sortedRepos[index].FullName
80+
desc := sortedRepos[index].Description
81+
if !clients.Config.WithExperimentOn(experiment.Charm) {
82+
desc += "\n https://github.com/" + sortedRepos[index].FullName
83+
}
84+
return desc
7385
},
7486
Flag: clients.Config.Flags.Lookup("template"),
87+
Help: fmt.Sprintf("Guided tutorials can be found at %s", style.LinkText("https://docs.slack.dev/samples")),
7588
PageSize: 4, // Supports standard terminal height (24 rows)
7689
Required: true,
7790
Template: embedPromptSamplesTmpl,
@@ -127,18 +140,3 @@ func sortRepos(sampleRepos []create.GithubRepo) []create.GithubRepo {
127140
})
128141
return sortedRepos
129142
}
130-
131-
// createSelectOptions takes in a list of repositories
132-
// and returns an array of strings, each value being
133-
// equal to the repository name (ie, deno-starter-template)
134-
// and prepended with a number for a prompt visual aid
135-
func createSelectOptions(filteredRepos []create.GithubRepo) []string {
136-
// Create a slice of repository names to use as
137-
// the primary item selection in the prompt
138-
selectOptions := make([]string, 0)
139-
for i, f := range filteredRepos {
140-
selectOption := fmt.Sprint(i+1, ". ", f.Name)
141-
selectOptions = append(selectOptions, selectOption)
142-
}
143-
return selectOptions
144-
}

cmd/project/create_samples_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,3 @@ func TestSamples_SortRepos(t *testing.T) {
174174
assert.Equal(t, sortedRepos[3].StargazersCount, 0, "Expected sortedRepos[3].StargazersCount to equal 0")
175175
assert.Equal(t, sortedRepos[3].Description, "This is a new sample")
176176
}
177-
178-
func TestSamples_CreateSelectOptions(t *testing.T) {
179-
selectOptions := createSelectOptions(mockGitHubRepos)
180-
assert.Equal(t, len(selectOptions), 4, "Expected selectOptions length to be 4")
181-
assert.Contains(t, selectOptions[0], mockGitHubRepos[0].Name, "Expected selectOptions[0] to contain mockGitHubRepos[0].Name")
182-
}

cmd/project/create_template.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"time"
2222

2323
"github.com/slackapi/slack-cli/internal/api"
24-
"github.com/slackapi/slack-cli/internal/experiment"
2524
"github.com/slackapi/slack-cli/internal/iostreams"
2625
"github.com/slackapi/slack-cli/internal/pkg/create"
2726
"github.com/slackapi/slack-cli/internal/shared"
@@ -107,16 +106,6 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory,
107106
// Check if a category shortcut was provided
108107
if categoryShortcut == "agent" {
109108
categoryID = "slack-cli#ai-apps"
110-
} else if clients.Config.WithExperimentOn(experiment.Charm) {
111-
result, err := charmPromptTemplateSelection(ctx, clients)
112-
if err != nil {
113-
return create.Template{}, slackerror.ToSlackError(err)
114-
}
115-
if result.CategoryID == viewMoreSamples || result.TemplateRepo == viewMoreSamples {
116-
selectedTemplate = viewMoreSamples
117-
} else {
118-
selectedTemplate = result.TemplateRepo
119-
}
120109
} else {
121110
// Prompt for the category
122111
promptForCategory := "Select an app:"
@@ -132,9 +121,6 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory,
132121

133122
// Prompt to choose a category
134123
selection, err := clients.IO.SelectPrompt(ctx, promptForCategory, titlesForCategory, iostreams.SelectPromptConfig{
135-
Description: func(value string, index int) string {
136-
return optionsForCategory[index].Description
137-
},
138124
Flag: clients.Config.Flags.Lookup("template"),
139125
Required: true,
140126
Template: templateForCategory,
@@ -168,9 +154,6 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory,
168154

169155
// Prompt to choose a template
170156
selection, err := clients.IO.SelectPrompt(ctx, prompt, titles, iostreams.SelectPromptConfig{
171-
Description: func(value string, index int) string {
172-
return options[index].Description
173-
},
174157
Flag: clients.Config.Flags.Lookup("template"),
175158
Required: true,
176159
Template: template,

cmd/project/create_template_charm.go

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)