Fixed -L shorthand bug for list command (#33) (#34)

* Fixed -L shorthand bug for list command (#33)

* Changed function name to TestListLimitShorthandUsingIncorrectLimit
This commit is contained in:
Enes
2022-09-18 10:19:38 +03:00
committed by GitHub
parent 235994ccc5
commit 2b273da8da
2 changed files with 13 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ func NewCmdList() *cobra.Command {
listCmd.Flags().StringVarP(&f.Repo, "repo", "R", "", "Select another repository for finding actions cache.")
listCmd.Flags().StringVarP(&f.Branch, "branch", "B", "", "Filter by branch")
listCmd.Flags().IntVarP(&f.Limit, "limit", "", 30, "Number of items to fetch between 1 and 100")
listCmd.Flags().IntVarP(&f.Limit, "limit", "L", 30, "Number of items to fetch between 1 and 100")
listCmd.Flags().StringVarP(&f.Key, "key", "", "", "Filter by key")
listCmd.Flags().StringVarP(&f.Order, "order", "", "", "Order of caches returned (asc/desc)")
listCmd.Flags().StringVarP(&f.Sort, "sort", "", "", "Sort fetched caches (last-used/size/created-at)")

View File

@@ -62,6 +62,18 @@ func TestListWithIncorrectLimit(t *testing.T) {
assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending()))
}
func TestListLimitShorthandUsingIncorrectLimit(t *testing.T) {
t.Cleanup(gock.Off)
cmd := NewCmdList()
cmd.SetArgs([]string{"-L", "102", "--repo", "testOrg/testRepo"})
err := cmd.Execute()
assert.NotNil(t, err)
assert.Equal(t, err, fmt.Errorf("102 is not a valid integer value for limit flag. Allowed values: 1-100"))
assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending()))
}
func TestListWithIncorrectOrder(t *testing.T) {
t.Cleanup(gock.Off)