Compare commits

..

2 Commits

Author SHA1 Message Date
9eb35ec52d
added en.Finish 2024-09-30 22:00:28 +03:00
be165e5033 added tests and test cases 2024-09-30 19:55:13 +03:00
2 changed files with 108 additions and 1 deletions

View File

@ -78,3 +78,59 @@ func TestTerms(t *testing.T) {
}
}
}
func TestAccountRegistrationRejectTerms(t *testing.T) {
en, _ := enginetest.TestEngine("session1234112")
defer en.Finish()
var err error
ctx := context.Background()
sessions := testData
for _, session := range sessions {
groups := driver.FilterGroupsByName(session.Groups, "account_creation_reject_terms")
for _, group := range groups {
for _, step := range group.Steps {
cont, _ := en.Exec(ctx, []byte(step.Input))
if cont {
w := bytes.NewBuffer(nil)
_, err = en.Flush(ctx, w)
if err != nil {
t.Fatal(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 TestAccountRegistrationInvalidPin(t *testing.T) {
en, _ := enginetest.TestEngine("session1234112")
defer en.Finish()
var err error
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, _ := en.Exec(ctx, []byte(step.Input))
if cont {
w := bytes.NewBuffer(nil)
_, err = en.Flush(ctx, w)
if err != nil {
t.Fatal(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)
}
}
}
}
}
}

View File

@ -23,7 +23,7 @@
},
{
"input": "1234",
"expectedContent": "Enter your four number PIN again:"
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
}
]
},
@ -43,6 +43,57 @@
"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": [
{
"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": "1111",
"expectedContent": "The PIN is not a match. Try again\n1:retry\n9:Quit"
},
{
"input": "1",
"expectedContent": "Enter your four number PIN again:"
},
{
"input": "1234",
"expectedContent": "Your account is being created...Thank you for using Sarafu. Goodbye!"
}
]
}
]