Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunOneWith ¶
Run initializes the tester, runs a test, and closes it, calling Fatalf on any error.
func RunTestWith ¶
RunTestWith runs a test using the specified basename and callback. This can be used multiple times within a Tester. The tester state is maintained across tests, allowing a sequence of calls that builds up and modifies tester state.
Types ¶
type Tester ¶
type Tester struct { goldenbase.Tester CreateHandler func(r *Tester) http.Handler Callback func() (*http.Request, error) }
Tester provides the structure for running API unit tests. For a single test, the typical calling sequence is:
r := NewTester(handlerCreateFunc) if err := r.Run(t, basename, callback); err != nil { t.Fatal(err) }
For multiple tests, maintaining the Tester state across tests as it changes:
r := NewTester(handlerCreateFunc) if err := r.Init(); err != nil { t.Fatal(err) } if err := r.RunTestWith(t, basename, callback); err != nil { t.Fatal(err) } if err := r.RunTestWith(t, basename2, callback2); err != nil { t.Fatal(err) } if err := r.Close(); err != nil { t.Fatal(err) }
(Error handling should be better than the minimal error handling shown above.)
func NewTester ¶
NewTester creates a new instance of a Tester that will use the specified function to create an http.Handler.
type TesterApi ¶
type TesterApi interface { goldenbase.MultiRunner SetBaseNameAndCallback(basename string, callback func() (*http.Request, error)) }