Skip to content

Instantly share code, notes, and snippets.

@zdunecki
Last active September 14, 2021 10:03
Show Gist options
  • Save zdunecki/f35fb45fc0399abc8aed4d34b67d644f to your computer and use it in GitHub Desktop.
Save zdunecki/f35fb45fc0399abc8aed4d34b67d644f to your computer and use it in GitHub Desktop.
Testing DSL/QL concept
seed().
upgrade().
createWebsites(createWebsitesP{blocked: true}).
goFreemium().
freemiumTask(freemiumTaskP{mockTime: true}).
checkBlockedWebsites(checkBlockedWebsitesP{expect: []})
stateMachine := []interface{
{Name: "upgrade", Src: []string{"trial"}, Dst: "has_plan"},
{Name: "goFreemium", Src: []string{"has_plan"}, Dst: "has_freemium", MiddleState: "upgrade"},
{Name: "goFreemium", Src: []string{"has_plan"}, Dst: "has_future_freemium", MiddleState: "downgrade"}
}
`function Abc($mockTime) -> seed->upgrade->createWebsites(blocked=true)->goFreemium->freemiumTask(mockTime=$mockTime)->checkBlockedWebsites(expect=$expect)`
testQuery := `Abc(true)`
testQuery2 := `Abc(false)`
t := tests.New()
t.StateMachine(stateMachine)
t.Do(testQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment