Skip to content

Add Modular Test feature #82

@regisphilibert

Description

@regisphilibert

Initial idea was to build #18 but we should probably surface this as a public feature and setup test for huge ourselves.

The concept is, for every partial that the user wants to test they will have to create its homonymous testing partial

func/GetFeaturedImage.html < the partial
func/GetFeaturedImage__test.html < the test partial.

The test partial will return a list of tests each having an input and and an output. The latter will be compared to the partial returned value.

W'll then have one or more public huge function which returns a list of the tests along with a name and a test value (true or false).

Example:

partials/func/GetFeaturedImage.html

{{ $image := "/no-image.jpg" }}
{{ with .Params.featured_image }}
  {{ $image = . }}
{{ end }}
{{ return $image}}

The following test partials will return an array of tests.
partials/func/GetFeaturedImage__test.html

{{ return slice
  (dict
    "name" "homepage"
    "input" site.Home
    "output" "/from_home.jpg"
  )
  (dict
    "name" "about page"
    "input" (site.GetPage "/about")
    "output" "/no-image.jpg"
  )
}}

Usage

User can use one or more functions which would perform the tests and return a "list" of logs for each tests.

We could have huge/tests/GetFails for example to only list the failing test or huge/tests/GetAll etc... This would return a list of arrays with the name of the name of the partial, the name of the test etc...

- partial func/GetFeaturedImage.html
  name: homepage
  success true
- partial func/GetFeaturedImage.html 
  name: about page
  success true

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions