menu-traversals #108

Closed
carlos wants to merge 72 commits from menu-traversals into master
4 changed files with 20 additions and 125 deletions
Showing only changes of commit 079529ebac - Show all commits

View File

@ -25,7 +25,7 @@ func extractPublicKey(response []byte) string {
return "" return ""
} }
func TestUserRegistration(t *testing.T) { func TestAccountCreationSuccessful(t *testing.T) {
en, fn := enginetest.TestEngine("session1234112") en, fn := enginetest.TestEngine("session1234112")
defer fn() defer fn()
ctx := context.Background() ctx := context.Background()
@ -58,36 +58,6 @@ func TestUserRegistration(t *testing.T) {
} }
} }
func TestTerms(t *testing.T) {
en, fn := enginetest.TestEngine("session1234112_a")
defer fn()
ctx := context.Background()
sessions := testData
for _, session := range sessions {
groups := driver.FilterGroupsByName(session.Groups, "account_creation_accept_terms")
for _, group := range groups {
for _, step := range group.Steps {
_, err := en.Exec(ctx, []byte(step.Input))
if err != nil {
t.Fatalf("Test case '%s' failed during Exec: %v", group.Name, err)
}
w := bytes.NewBuffer(nil)
_, err = en.Flush(ctx, w)
if err != nil {
t.Fatalf("Test case '%s' failed during Flush: %v", group.Name, err)
}
b := w.Bytes()
if !bytes.Equal(b, []byte(step.ExpectedContent)) {
t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", step.ExpectedContent, b)
}
}
}
}
}
func TestAccountRegistrationRejectTerms(t *testing.T) { func TestAccountRegistrationRejectTerms(t *testing.T) {
en, fn := enginetest.TestEngine("session1234112_b") en, fn := enginetest.TestEngine("session1234112_b")
defer fn() defer fn()
@ -119,37 +89,6 @@ func TestAccountRegistrationRejectTerms(t *testing.T) {
} }
} }
func TestAccountRegistrationInvalidPin(t *testing.T) {
en, fn := enginetest.TestEngine("session1234112_c")
defer fn()
ctx := context.Background()
sessions := testData
for _, session := range sessions {
groups := driver.FilterGroupsByName(session.Groups, "account_creation_invalid_pin")
for _, group := range groups {
for _, step := range group.Steps {
cont, err := en.Exec(ctx, []byte(step.Input))
if err != nil {
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
return
}
if !cont {
break
}
w := bytes.NewBuffer(nil)
if _, err := en.Flush(ctx, w); err != nil {
t.Fatalf("Test case '%s' failed during Flush: %v", group.Name, err)
}
b := w.Bytes()
if !bytes.Equal(b, []byte(step.ExpectedContent)) {
t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", step.ExpectedContent, b)
}
}
}
}
}
func TestSendWithInvalidInputs(t *testing.T) { func TestSendWithInvalidInputs(t *testing.T) {
en, fn := enginetest.TestEngine("session1234112") en, fn := enginetest.TestEngine("session1234112")
defer fn() defer fn()

View File

@ -1 +1 @@
Enter a new four number PIN Enter a new four number PIN:

View File

@ -4,66 +4,6 @@
"groups": [ "groups": [
{ {
"name": "account_creation_successful", "name": "account_creation_successful",
"steps": [
{
"input": "",
"expectedContent": "Welcome to Sarafu Network\nPlease select a language\n0:english\n1:kiswahili"
},
{
"input": "0",
"expectedContent": "Do you agree to terms and conditions?\n0:yes\n1:no"
},
{
"input": "0",
"expectedContent": "Please enter a new four number PIN for your account:\n0:Exit"
},
{
"input": "1234",
"expectedContent": "Enter your four number PIN again:"
},
{
"input": "1234",
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
}
]
},
{
"name": "account_creation_accept_terms",
"steps": [
{
"input": "",
"expectedContent": "Welcome to Sarafu Network\nPlease select a language\n0:english\n1:kiswahili"
},
{
"input": "0",
"expectedContent": "Do you agree to terms and conditions?\n0:yes\n1:no"
},
{
"input": "0",
"expectedContent": "Please enter a new four number PIN for your account:\n0:Exit"
}
]
},
{
"name": "account_creation_reject_terms",
"steps": [
{
"input": "",
"expectedContent": "Welcome to Sarafu Network\nPlease select a language\n0:english\n1:kiswahili"
},
{
"input": "0",
"expectedContent": "Do you agree to terms and conditions?\n0:yes\n1:no"
},
{
"input": "1",
"expectedContent": "Thank you for using Sarafu. Goodbye!"
}
]
},
{
"name": "account_creation_invalid_pin",
"steps": [ "steps": [
{ {
"input": "", "input": "",
@ -93,7 +33,23 @@
"input": "1234", "input": "1234",
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!" "expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
} }
]
},
{
"name": "account_creation_reject_terms",
"steps": [
{
"input": "",
"expectedContent": "Welcome to Sarafu Network\nPlease select a language\n0:english\n1:kiswahili"
},
{
"input": "0",
"expectedContent": "Do you agree to terms and conditions?\n0:yes\n1:no"
},
{
"input": "1",
"expectedContent": "Thank you for using Sarafu. Goodbye!"
}
] ]
}, },
{ {