mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: address verified review findings (cli-core-1)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
12 files changed
+181
-21
No files matched your search
@@ -4,6 +4,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -93,6 +95,9 @@ func TestArgumentErrorsShowTheUsageLine(t *testing.T) {
|
||||
{[]string{"pr", "checkout"}, "missing pull request number\nUsage: tea pr checkout {<number> | <url> | <branch>} [flags]"},
|
||||
{[]string{"run", "view"}, "missing run ID\nUsage: tea run view [<run-id>] [flags]"},
|
||||
{[]string{"release", "asset", "edit", "v1"}, "missing asset\nUsage: tea release asset edit <tag> <asset> [flags]"},
|
||||
{[]string{"time", "create"}, "missing issue number\nUsage: tea time create {<number> | <url>} <duration> [flags]"},
|
||||
{[]string{"milestone", "issue", "add", "v1.0"}, "missing issue number\nUsage: tea milestone issue add <milestone> {<number> | <url>}... [flags]"},
|
||||
{[]string{"branch", "protect", "main", "--pattern", "release/*"}, "--pattern cannot be combined with branch names\nUsage: tea branch protect <branch>... [flags]"},
|
||||
{[]string{"repo", "clone"}, "missing repository\nUsage: tea repo clone <repository> [<directory>] [-- <gitflags>...] [flags]"},
|
||||
} {
|
||||
requireUsageBeforeRequests(t, tc.want, tc.args...)
|
||||
@@ -108,3 +113,12 @@ func TestLimitAcceptsShorthandUpToOneThousand(t *testing.T) {
|
||||
require.Equal(t, 1000, limit)
|
||||
require.ErrorContains(t, cmd.Flags().Parse([]string{"-L", "1001"}), "must be 1..1000")
|
||||
}
|
||||
|
||||
func TestPageRejectsValuesThatOverflowTheOffset(t *testing.T) {
|
||||
var limit, page int
|
||||
cmd := &cobra.Command{Use: "list"}
|
||||
pageFlags(cmd, &limit, &page)
|
||||
require.NoError(t, cmd.Flags().Parse([]string{"--page", strconv.Itoa(maxPage)}))
|
||||
require.Equal(t, maxPage, page)
|
||||
require.ErrorContains(t, cmd.Flags().Parse([]string{"--page", strconv.Itoa(math.MaxInt)}), "--page")
|
||||
}
|
||||
Reference in new issue
Block a user