Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Exit if error: describeTable with no parameters
  • Loading branch information
felipe88alves authored and onsi committed Sep 26, 2022
1 parent 1be2427 commit a4c9865
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions table_dsl.go
Expand Up @@ -135,6 +135,10 @@ func generateTable(description string, args ...interface{}) {
return "Entry: " + strings.Join(out, ", ")
}

if len(args) == 1 {
exitIfErr(types.GinkgoErrors.MissingParametersForTableFunction(cl))
}

for i, arg := range args {
switch t := reflect.TypeOf(arg); {
case t == nil:
Expand Down
9 changes: 9 additions & 0 deletions types/errors.go
Expand Up @@ -380,6 +380,15 @@ func (g ginkgoErrors) InvalidEntryDescription(cl CodeLocation) error {
}
}

func (g ginkgoErrors) MissingParametersForTableFunction(cl CodeLocation) error {
return GinkgoError{
Heading: fmt.Sprintf("No parameters have been passed to the Table Function"),
Message: fmt.Sprintf("The Table Function expected at least 1 parameter"),
CodeLocation: cl,
DocLink: "table-specs",
}
}

func (g ginkgoErrors) IncorrectParameterTypeForTable(i int, name string, cl CodeLocation) error {
return GinkgoError{
Heading: "DescribeTable passed incorrect parameter type",
Expand Down

0 comments on commit a4c9865

Please sign in to comment.