|
| 1 | +//go:build !integration |
| 2 | + |
| 3 | +package cli |
| 4 | + |
| 5 | +import ( |
| 6 | + "os" |
| 7 | + "path/filepath" |
| 8 | + "runtime" |
| 9 | + "strings" |
| 10 | + "testing" |
| 11 | + |
| 12 | + "github.com/stretchr/testify/assert" |
| 13 | + "github.com/stretchr/testify/require" |
| 14 | +) |
| 15 | + |
| 16 | +func TestAuditCommandDescriptionsAreConsistent(t *testing.T) { |
| 17 | + cmd := NewAuditCommand() |
| 18 | + |
| 19 | + assert.Contains(t, cmd.Short, "workflow runs", "audit short description should describe multiple run inputs") |
| 20 | + assert.Contains(t, cmd.Long, "Audit one or more workflow runs", "audit long description should describe multiple run inputs") |
| 21 | +} |
| 22 | + |
| 23 | +func TestTrialCommandUsesStandardExamplesHeading(t *testing.T) { |
| 24 | + cmd := NewTrialCommand(func(string) error { return nil }) |
| 25 | + |
| 26 | + assert.Contains(t, cmd.Long, "Examples:", "trial long help should use the standard examples heading") |
| 27 | + assert.NotContains(t, cmd.Long, "Single workflow:", "trial long help should avoid custom example section headings") |
| 28 | + assert.NotContains(t, cmd.Long, "Multiple workflows (for comparison):", "trial long help should avoid custom example section headings") |
| 29 | + assert.NotContains(t, cmd.Long, "Workflows from different repositories:", "trial long help should avoid custom example section headings") |
| 30 | + assert.NotContains(t, cmd.Long, "Repository mode examples:", "trial long help should avoid custom example section headings") |
| 31 | + assert.NotContains(t, cmd.Long, "Repeat and cleanup examples:", "trial long help should avoid custom example section headings") |
| 32 | + assert.NotContains(t, cmd.Long, "Auto-merge examples:", "trial long help should avoid custom example section headings") |
| 33 | + assert.NotContains(t, cmd.Long, "Advanced examples:", "trial long help should avoid custom example section headings") |
| 34 | +} |
| 35 | + |
| 36 | +func TestUpdateDocsIncludeCoolDownOption(t *testing.T) { |
| 37 | + _, currentFile, _, ok := runtime.Caller(0) |
| 38 | + require.True(t, ok, "should resolve current test file path") |
| 39 | + |
| 40 | + docsPath := filepath.Join(filepath.Dir(currentFile), "..", "..", "docs", "src", "content", "docs", "setup", "cli.md") |
| 41 | + content, err := os.ReadFile(docsPath) |
| 42 | + require.NoError(t, err, "should read CLI setup docs") |
| 43 | + |
| 44 | + text := string(content) |
| 45 | + updateIndex := strings.Index(text, "#### `update`") |
| 46 | + require.NotEqual(t, -1, updateIndex, "CLI setup docs should contain the update section") |
| 47 | + |
| 48 | + updateSection := text[updateIndex:] |
| 49 | + assert.Contains(t, updateSection, "`--cool-down`", "update docs options should include --cool-down") |
| 50 | +} |
0 commit comments