httptest

package module
v0.0.0-...-c1cfb8f Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 10 Imported by: 0

README

httptest

HTTP testing made easy for layered Web applications in Go.

Layered Web Applications

Non-trivial applications should be layered.

layered-app

For layered Web applications:

  • HTTP Server/Client should be separated from Service (i.e. the business rules)
  • HTTP Server should call an interface implemented by Service
  • HTTP Client should implement an interface defined in Service

Installation

Make a custom build of protogo:

$ protogo build --plugin=github.com/protogodev/httptest

Or build from a local fork:

$ protogo build --plugin=github.com/protogodev/httptest=../my-fork
Usage
$ protogo httptest -h
Usage: protogo httptest --mode=STRING --spec=STRING <source-file> <interface-name>

Arguments:
  <source-file>       source-file
  <interface-name>    interface-name

Flags:
  -h, --help           Show context-sensitive help.

      --mode=STRING    generation mode (server or client)
      --spec=STRING    the test specification in YAML
      --out=STRING     output filename (default "./<srcPkgName>_<mode>_test.go")
      --fmt            whether to make the test code formatted

Examples

See examples/usersvc.

Documentation

Check out the Godoc.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Mode             string `name:"mode" required:"" enum:"server,client" help:"generation mode (server or client)"`
	TestSpecFileName string `name:"spec" required:"" help:"the test specification in YAML"`
	OutFileName      string `name:"out" help:"output filename (default \"./<srcPkgName>_<mode>_test.go\")"`
	Formatted        bool   `name:"fmt" default:"true" help:"whether to make the test code formatted"`
}

func (*Generator) Generate

func (g *Generator) Generate(data *ifacetool.Data) (*generator.File, error)

Directories

Path Synopsis
examples
usersvc module

Jump to

Keyboard shortcuts

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