-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gender conversion from enumutils to healthCRM gender types
- Loading branch information
1 parent
42c4f2f
commit 87e0d00
Showing
4 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package healthcrm | ||
|
||
import "github.com/savannahghi/enumutils" | ||
|
||
// ConvertEnumutilsGenderToCRMGender converts an enumutils Gender to a CRM gender type | ||
func ConvertEnumutilsGenderToCRMGender(gender enumutils.Gender) GenderType { | ||
switch gender { | ||
case enumutils.GenderMale: | ||
return GenderTypeMale | ||
|
||
case enumutils.GenderFemale: | ||
return GenderTypeFemale | ||
|
||
case enumutils.GenderAgender, enumutils.GenderBigender, enumutils.GenderGenderQueer, | ||
enumutils.GenderNonBinary, enumutils.GenderTransGender, enumutils.GenderTwoSpirit, enumutils.GenderOther: | ||
return GenderTypeOther | ||
|
||
case enumutils.GenderPreferNotToSay: | ||
return GenderTypeASKU | ||
|
||
case enumutils.GenderUnknown: | ||
return GenderTypeUNK | ||
default: | ||
return GenderTypeUNK | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package healthcrm | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/savannahghi/enumutils" | ||
) | ||
|
||
func TestConvertEnumutilsGenderToCRMGender(t *testing.T) { | ||
type args struct { | ||
gender enumutils.Gender | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
want GenderType | ||
}{ | ||
{ | ||
name: "success: get male gender", | ||
args: args{ | ||
gender: enumutils.Gender("male"), | ||
}, | ||
want: GenderTypeMale, | ||
}, | ||
{ | ||
name: "success: get female gender", | ||
args: args{ | ||
gender: enumutils.GenderFemale, | ||
}, | ||
want: GenderTypeFemale, | ||
}, | ||
{ | ||
name: "success: get other gender", | ||
args: args{ | ||
gender: enumutils.GenderBigender, | ||
}, | ||
want: GenderTypeOther, | ||
}, | ||
{ | ||
name: "success: get ask but not unknown", | ||
args: args{ | ||
gender: enumutils.GenderPreferNotToSay, | ||
}, | ||
want: GenderTypeASKU, | ||
}, | ||
{ | ||
name: "success: get unknown gender", | ||
args: args{ | ||
gender: enumutils.GenderUnknown, | ||
}, | ||
want: GenderTypeUNK, | ||
}, | ||
{ | ||
name: "success: get unknown gender", | ||
args: args{ | ||
gender: enumutils.Gender("invalide"), | ||
}, | ||
want: GenderTypeUNK, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := ConvertEnumutilsGenderToCRMGender(tt.args.gender); got != tt.want { | ||
t.Errorf("ConvertEnumutilsGenderToCRMGender() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |