File: replay.go

package info (click to toggle)
golang-github-leanovate-gopter 0.2.9%2Bgit20210201.bbbf00e-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 696 kB
  • sloc: makefile: 37
file content (18 lines) | stat: -rw-r--r-- 627 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package commands

import (
	"github.com/leanovate/gopter"
)

// Replay a sequence of commands on a system for regression testing
func Replay(systemUnderTest SystemUnderTest, initialState State, commands ...Command) *gopter.PropResult {
	sequentialCommands := make([]shrinkableCommand, 0, len(commands))
	for _, command := range commands {
		sequentialCommands = append(sequentialCommands, shrinkableCommand{command: command, shrinker: gopter.NoShrinker})
	}
	actions := actions{
		initialStateProvider: func() State { return initialState },
		sequentialCommands:   sequentialCommands,
	}
	return actions.run(systemUnderTest)
}