test

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadHTMLFileOrFail

func ReadHTMLFileOrFail(t *testing.T, host string) *goquery.Document

ReadHTMLFileOrFail attempts to read an HTML file from the testdata directory and then load it into a Document. The filename is formed by adding a .html suffix name and then appending it to the testdata directory to form the file path. Any failures are reported with t.Fatal().

func Verify

func Verify(t *testing.T, wantOK bool, gotOK bool, wantVal any, gotVal any)

Verify checks whether wantOK matches with gotOK and reports failures with t.Errorf(). If got OK is set to true then it also checks that wantValue matches with gotValue, and similarly reports failures with t.Errorf().

Types

type Scraper

type Scraper struct {
	Author        string
	Categories    []string
	CookTime      time.Duration
	Cuisine       []string
	Description   string
	ImageURL      string
	Ingredients   []string
	Instructions  []string
	Language      string
	Name          string
	Nutrition     recipe.Nutrition
	PrepTime      time.Duration
	SuitableDiets []recipe.Diet
	TotalTime     time.Duration
	Yields        string
}

Scraper is a struct that helps test packages to test values returned by a recipe.Scraper. Clients should fill in the values of the struct that they expect to be returned by the recipe.Scraper and then call Run(). Defined values will be validated for an exact match and zero values will be validated that nothing is returned.

func (*Scraper) Run

func (s *Scraper) Run(t *testing.T, scraper recipe.Scraper)

Run runs the test and compares struct values against those returned by the scraper. Any failures are reported using t.Error().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL