Skip to content

Commit

Permalink
feat: substitute revision cpu and memory limits as env vars (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: Otieno Calvine <nyarangaotieno@gmail.com>

Co-authored-by: Calvine Otieno <calvine.otieno@healthcloud.co.ke>
  • Loading branch information
NYARAS and Calvine Otieno committed Aug 6, 2021
1 parent 29744d9 commit 3fcfe82
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -51,6 +51,9 @@ env:
JWT_KEY: ${{ secrets.JWT_KEY }}
SAVANNAH_ADMIN_EMAIL: ${{ secrets.SAVANNAH_ADMIN_EMAIL }}

concurrency:
group: lint-and-test

jobs:
lint_and_test:
strategy:
Expand Down
10 changes: 5 additions & 5 deletions cloudbuild.yaml
Expand Up @@ -18,10 +18,10 @@ steps:
'--region', 'europe-west1',
'--platform', 'managed',
'--allow-unauthenticated',
'--min-instances', '1',
'--max-instances', '4',
'--memory', '1Gi',
'--cpu', '1',
'--min-instances', '${_MIN_INST}',
'--max-instances', '${_MAX_INST}',
'--memory', '${_MEMORY_LIMIT}',
'--cpu', '${_CPU}',
'--set-secrets', '/tmp/secrets/.env=${_SECRET_NAME}:latest',
'--timeout', '59m59s'
]
Expand All @@ -31,12 +31,12 @@ steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: [
'run',
'services',
'update-traffic',
"${_SERVICE_NAME}",
'--to-latest',
'--region', 'europe-west1',
'--platform', 'managed',
'--allow-unauthenticated',
]

images:
Expand Down
9 changes: 9 additions & 0 deletions pkg/onboarding/presentation/rest/handlers_test.go
Expand Up @@ -649,6 +649,15 @@ func TestHandlersInterfacesImpl_CreateUserWithPhoneNumber(t *testing.T) {
return nil
}

fakeRepo.GetRolesByIDsFn = func(ctx context.Context, roleIDs []string) (*[]profileutils.Role, error) {
roles := []profileutils.Role{
{
ID: uuid.NewString(),
},
}
return &roles, nil
}

fakeRepo.GetUserCommunicationsSettingsFn = func(ctx context.Context, profileID string) (*profileutils.UserCommunicationsSetting, error) {
return &profileutils.UserCommunicationsSetting{
ID: "111",
Expand Down
2 changes: 0 additions & 2 deletions pkg/onboarding/repository/mock/onboarding.go
Expand Up @@ -142,8 +142,6 @@ type FakeOnboardingRepository struct {

GetUserCommunicationsSettingsFn func(ctx context.Context, profileID string) (*profileutils.UserCommunicationsSetting, error)

GetNavActionsFn func(ctx context.Context, role profileutils.RoleType) (*profileutils.NavigationActions, error)

SetUserCommunicationsSettingsFn func(ctx context.Context, profileID string,
allowWhatsApp *bool, allowTextSms *bool, allowPush *bool, allowEmail *bool) (*profileutils.UserCommunicationsSetting, error)

Expand Down
19 changes: 14 additions & 5 deletions pkg/onboarding/usecases/agent_unit_test.go
Expand Up @@ -859,6 +859,12 @@ func TestAgentUseCaseImpl_ActivateAgent(t *testing.T) {
fakeBaseExt.GetLoggedInUserFn = func(ctx context.Context) (*dto.UserInfo, error) {
return nil, fmt.Errorf("failed. could not get logged in user")
}
fakeRepo.GetUserProfileByIDFn = func(ctx context.Context, id string, suspended bool) (*profileutils.UserProfile, error) {
return &profileutils.UserProfile{}, nil
}
fakeRepo.UpdateSuspendedFn = func(ctx context.Context, id string, status bool) error {
return fmt.Errorf("failed to unsuspend/activate agent account")
}
}

if tt.name == "invalid:loggedin_user_does_not_have_employee_role" {
Expand All @@ -868,11 +874,8 @@ func TestAgentUseCaseImpl_ActivateAgent(t *testing.T) {
}, nil
}

fakeRepo.GetUserProfileByUIDFn = func(ctx context.Context, uid string, suspended bool) (*profileutils.UserProfile, error) {
return &profileutils.UserProfile{
ID: "c9d62c7e-93e5-44a6-b503-6fc159c1782f",
VerifiedUIDS: []string{"f4f39af7-5b64-4c2f-91bd-42b3af315a4e"},
}, nil
fakeRepo.GetUserProfileByIDFn = func(ctx context.Context, id string, suspended bool) (*profileutils.UserProfile, error) {
return &profileutils.UserProfile{}, nil
}
}

Expand Down Expand Up @@ -1030,6 +1033,12 @@ func TestAgentUseCaseImpl_DeactivateAgent(t *testing.T) {
fakeBaseExt.GetLoggedInUserFn = func(ctx context.Context) (*dto.UserInfo, error) {
return nil, fmt.Errorf("failed. could not get logged in user")
}
fakeRepo.GetUserProfileByIDFn = func(ctx context.Context, id string, suspended bool) (*profileutils.UserProfile, error) {
return &profileutils.UserProfile{}, nil
}
fakeRepo.UpdateSuspendedFn = func(ctx context.Context, id string, status bool) error {
return fmt.Errorf("failed to unsuspend/activate agent account")
}
}

if tt.name == "invalid:loggedin_user_does_not_have_employee_role" {
Expand Down
39 changes: 5 additions & 34 deletions pkg/onboarding/usecases/login_unit_test.go
Expand Up @@ -5,9 +5,7 @@ import (
"fmt"
"testing"

"github.com/savannahghi/onboarding/pkg/onboarding/application/common"
"github.com/savannahghi/onboarding/pkg/onboarding/application/dto"
"github.com/segmentio/ksuid"

"github.com/google/uuid"
"github.com/savannahghi/feedlib"
Expand Down Expand Up @@ -369,40 +367,13 @@ func TestProfileUseCaseImpl_LoginByPhone(t *testing.T) {
AllowPush: true,
}, nil
}

fakeRepo.GetNavActionsFn = func(ctx context.Context, role profileutils.RoleType) (*profileutils.NavigationActions, error) {
navs := profileutils.NavigationActions{
Primary: []profileutils.NavAction{
{
Title: common.HomeNavActionTitle,
OnTapRoute: common.HomeRoute,
Icon: feedlib.Link{
ID: ksuid.New().String(),
URL: common.HomeNavActionURL,
LinkType: feedlib.LinkTypeSvgImage,
Title: common.HomeNavActionTitle,
Description: common.HomeNavActionDescription,
Thumbnail: common.HomeNavActionURL,
},
Favourite: false,
},
{
Title: common.HelpNavActionTitle,
OnTapRoute: common.GetHelpRouteRoute,
Icon: feedlib.Link{
ID: ksuid.New().String(),
URL: common.HelpNavActionURL,
LinkType: feedlib.LinkTypeSvgImage,
Title: common.HelpNavActionTitle,
Description: common.HelpNavActionDescription,
Thumbnail: common.HelpNavActionURL,
},
Favourite: false,
},
fakeRepo.GetRolesByIDsFn = func(ctx context.Context, roleIDs []string) (*[]profileutils.Role, error) {
roles := []profileutils.Role{
{
ID: uuid.NewString(),
},
Secondary: []profileutils.NavAction{},
}
return &navs, nil
return &roles, nil
}

}
Expand Down
4 changes: 0 additions & 4 deletions pkg/onboarding/usecases/profile_unit_test.go
Expand Up @@ -3901,10 +3901,6 @@ func TestProfileUseCaseImpl_RefreshNavigationActions(t *testing.T) {
return &profileutils.UserProfile{}, nil
}

fakeRepo.GetNavActionsFn = func(ctx context.Context, role profileutils.RoleType) (*profileutils.NavigationActions, error) {
return &profileutils.NavigationActions{}, nil
}

fakeRepo.GetRolesByIDsFn = func(ctx context.Context, roleIDs []string) (*[]profileutils.Role, error) {
roles := []profileutils.Role{
{
Expand Down
5 changes: 3 additions & 2 deletions pkg/onboarding/usecases/signup_unit_test.go
Expand Up @@ -357,8 +357,9 @@ func TestSignUpUseCasesImpl_CreateUserByPhone(t *testing.T) {
return nil
}

fakeRepo.GetNavActionsFn = func(ctx context.Context, role profileutils.RoleType) (*profileutils.NavigationActions, error) {
return &profileutils.NavigationActions{}, nil
fakeRepo.GetRolesByIDsFn = func(ctx context.Context, roleIDs []string) (*[]profileutils.Role, error) {
roles := []profileutils.Role{}
return &roles, nil
}
}

Expand Down

0 comments on commit 3fcfe82

Please sign in to comment.