Skip to content

Commit

Permalink
chore: cleanup and acceptance tests
Browse files Browse the repository at this point in the history
Remove unused configuration and add critical API acceptance tests

Signed-off-by: Otieno Calvine <nyarangaotieno@gmail.com>
  • Loading branch information
NYARAS committed Oct 1, 2021
1 parent 4b96145 commit addeb61
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 48 deletions.
46 changes: 0 additions & 46 deletions cloudbuild.yaml

This file was deleted.

1 change: 0 additions & 1 deletion gcloud.sh

This file was deleted.

6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -337,7 +339,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/savannahghi/converterandformatter v0.0.10/go.mod h1:DNqyfHojHOrll1/l6Y9UUSl97/TBiB08zcRWjaXbXRM=
Expand Down Expand Up @@ -379,6 +383,7 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
Expand Down Expand Up @@ -410,6 +415,7 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
Expand Down
5 changes: 5 additions & 0 deletions pkg/clinical/infrastructure/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/extensions"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/engagement"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/onboarding"
"github.com/savannahghi/firebasetools"
)

Expand All @@ -17,6 +18,7 @@ type Infrastructure struct {
FirestoreRepo Repository
Engagement engagement.ServiceEngagement
FirestoreClient *firestore.Client
Onboarding onboarding.ServiceOnboarding
}

// NewInfrastructureInteractor initializes a new Infrastructure
Expand All @@ -26,6 +28,8 @@ func NewInfrastructureInteractor() Infrastructure {
engagementClient := common.NewInterServiceClient("engagement", baseExtension)
engagement := engagement.NewServiceEngagementImpl(engagementClient, baseExtension)
firestoreDB := NewDBService()
onboardingClient := common.NewInterServiceClient("onboarding", baseExtension)
onboarding := onboarding.NewServiceOnboardingImpl(onboardingClient, baseExtension)

fc := firebasetools.FirebaseClient{}
fa, err := fc.InitFirebase()
Expand All @@ -43,5 +47,6 @@ func NewInfrastructureInteractor() Infrastructure {
firestoreDB,
engagement,
fsc,
onboarding,
}
}
1 change: 1 addition & 0 deletions pkg/clinical/presentation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func PrepareServer(
WriteTimeout: serverTimeoutSeconds * time.Second,
ReadTimeout: serverTimeoutSeconds * time.Second,
}
log.Infof("Server running at port %v", addr)
return srv
}

Expand Down
36 changes: 35 additions & 1 deletion pkg/clinical/usecases/patient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
auth "github.com/savannahghi/clinical/pkg/clinical/application/authorization"
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/common/helpers"
"github.com/savannahghi/clinical/pkg/clinical/application/dto"
"github.com/savannahghi/clinical/pkg/clinical/application/utils"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure"
Expand Down Expand Up @@ -964,7 +965,40 @@ func (c *ClinicalUseCaseImpl) AddNHIF(ctx context.Context, input *domain.SimpleN

// RegisterUser implements creates a user profile and simple patient registration
func (c *ClinicalUseCaseImpl) RegisterUser(ctx context.Context, input domain.SimplePatientRegistrationInput) (*domain.PatientPayload, error) {
return nil, nil
user, err := profileutils.GetLoggedInUser(ctx)

if err != nil {
return nil, fmt.Errorf("error, failed to get logged in user: %v", err)
}

log.Printf("loggedin user UID: %v", user.UID)

var primaryEmail string
if len(input.Emails) > 0 {
primaryEmail = input.Emails[0].Email
}

payload := dto.RegisterUserPayload{
UID: user.UID,
FirstName: input.Names[0].FirstName,
LastName: input.Names[0].LastName,
PhoneNumber: input.PhoneNumbers[0].Msisdn,
Gender: enumutils.Gender(input.Gender),
Email: primaryEmail,
DateOfBirth: input.BirthDate,
}

err = c.infrastructure.Onboarding.CreateUserProfile(ctx, payload)
if err != nil {
return nil, fmt.Errorf("failed to create a user profile: %v", err)
}

patient, err := c.RegisterPatient(ctx, input)
if err != nil {
return nil, fmt.Errorf("failed to create a patient profile: %v", err)
}

return patient, nil
}

// CreateUpdatePatientExtraInformation updates a patient's extra info
Expand Down

0 comments on commit addeb61

Please sign in to comment.