Skip to content

Commit

Permalink
Merge pull request #281 from nyaruka/fix_loc_tests
Browse files Browse the repository at this point in the history
Migrate templates in legacy HasState and HasWard tests
  • Loading branch information
rowanseymour authored May 3, 2018
2 parents a8db2db + 106e972 commit 459896d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
16 changes: 14 additions & 2 deletions legacy/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,24 @@ func migrateRule(baseLanguage utils.Language, exitMap map[string]flows.Exit, r R
case "district":
test := stringTest{}
err = json.Unmarshal(r.Test.Data, &test)
arguments = []string{test.Test}
migratedState, err := MigrateTemplate(test.Test, ExtraAsFunction)
if err != nil {
return routers.Case{}, err
}
arguments = []string{migratedState}

case "ward":
test := wardTest{}
err = json.Unmarshal(r.Test.Data, &test)
arguments = []string{test.District, test.State}
migratedDistrict, err := MigrateTemplate(test.District, ExtraAsFunction)
if err != nil {
return routers.Case{}, err
}
migratedState, err := MigrateTemplate(test.State, ExtraAsFunction)
if err != nil {
return routers.Case{}, err
}
arguments = []string{migratedDistrict, migratedState}

default:
return routers.Case{}, fmt.Errorf("migration of '%s' tests no supported", r.Test.Type)
Expand Down
10 changes: 5 additions & 5 deletions legacy/testdata/migrations/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@
{
"legacy_test": {
"type": "district",
"test": "Kigali"
"test": "@flow.state"
},
"expected_case": {
"uuid": "d2f852ec-7b4e-457f-ae7f-f8b243c49ff5",
"type": "has_district",
"arguments": ["Kigali"],
"arguments": ["@run.results.state"],
"exit_uuid": "c072ecb5-0686-40ea-8ed3-898dc1349783"
},
"expected_localization": {}
Expand Down Expand Up @@ -370,13 +370,13 @@
{
"legacy_test": {
"type": "ward",
"state": "Kigali",
"district": "Gasabo"
"state": "@flow.state",
"district": "@flow.district"
},
"expected_case": {
"uuid": "d2f852ec-7b4e-457f-ae7f-f8b243c49ff5",
"type": "has_ward",
"arguments": ["Gasabo", "Kigali"],
"arguments": ["@run.results.district", "@run.results.state"],
"exit_uuid": "c072ecb5-0686-40ea-8ed3-898dc1349783"
},
"expected_localization": {}
Expand Down

0 comments on commit 459896d

Please sign in to comment.