doctest

package
v0.5.14 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package doctest provides helper functions to test a documentation block of a function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTest

func RunTest(expectRequest bool, test func())

RunTest mocks an test http server.

Types

type Doc

type Doc struct {
	Description string
	Fields      map[string]string
}

Doc represents an documentation block.

func ParseDoc

func ParseDoc(s string) (*Doc, error)

ParseDoc parses an documentation block and returns an instance to Doc. It will parse Sections separated by a colon and populate them in the Doc.Fields field. Example: Take following input: Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Field1:

Hello World

Field2:

Good Bye World

Will return

Doc{
   Description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
   Fields: map[string]string{
       "Field1": "Hello World",
       "Field2": "Good Bye World",
   },
}.

Jump to

Keyboard shortcuts

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