Skip to content

Commit

Permalink
Lint and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwoberts committed Sep 9, 2024
1 parent aaa0b6b commit c133eed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/services/sqlstore/postgres/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestUserStorage_Register(t *testing.T) {
err = bus.Dispatch(demoTenantCtx, getUser)
Expect(err).IsNil()

Expect(getUser.Result.ID).Equals(int(6))
Expect(getUser.Result.ID).Equals(int(7))
Expect(getUser.Result.Role).Equals(enum.RoleCollaborator)
Expect(getUser.Result.Name).Equals("Rob Stark")
Expect(getUser.Result.Email).Equals("[email protected]")
Expand Down
5 changes: 4 additions & 1 deletion app/services/userlist/userlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ func addOrRemoveUserListUser(ctx context.Context, u *cmd.UserListHandleRoleChang
return err
}

updateUserListUser(ctx, &cmd.UserListUpdateUser{
err = updateUserListUser(ctx, &cmd.UserListUpdateUser{
Id: u.Id,
TenantId: user.Result.Tenant.ID,
Email: user.Result.Email,
Name: user.Result.Name,
})
if err != nil {
return err
}
return nil
}

Expand Down
27 changes: 18 additions & 9 deletions app/services/userlist/userlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestCreatTenant_Success(t *testing.T) {
Subdomain: "got",
}

bus.Dispatch(ctx, createCompanyCmd)
err := bus.Dispatch(ctx, createCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)
Expect(httpclientmock.RequestsHistory[0].URL.String()).Equals("https://push.userlist.com/companies")
Expand All @@ -64,7 +65,8 @@ func TestUpdateTenant_Success(t *testing.T) {
BillingStatus: enum.BillingActive,
}

bus.Dispatch(ctx, updateCompanyCmd)
err := bus.Dispatch(ctx, updateCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)
Expect(httpclientmock.RequestsHistory[0].URL.String()).Equals("https://push.userlist.com/companies")
Expand All @@ -83,7 +85,8 @@ func TestUpdateTenant_BillingStatusUpdatedIfSet(t *testing.T) {
BillingStatus: enum.BillingActive,
}

bus.Dispatch(ctx, updateCompanyCmd)
err := bus.Dispatch(ctx, updateCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -103,7 +106,8 @@ func TestUpdateTenant_BillingStatusNotUpdatedIfNotSet(t *testing.T) {
TenantId: 1,
}

bus.Dispatch(ctx, updateCompanyCmd)
err := bus.Dispatch(ctx, updateCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -122,7 +126,8 @@ func TestUpdateTenant_NameShouldUpdateIfSet(t *testing.T) {
TenantId: 1,
}

bus.Dispatch(ctx, updateCompanyCmd)
err := bus.Dispatch(ctx, updateCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -140,7 +145,8 @@ func TestUpdateTenant_NameShouldNotUpdateIfNotSet(t *testing.T) {
TenantId: 1,
}

bus.Dispatch(ctx, updateCompanyCmd)
err := bus.Dispatch(ctx, updateCompanyCmd)
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -154,11 +160,12 @@ func TestUpdateUser_NameOnly(t *testing.T) {
env.Config.HostMode = "multi"
reset()

bus.Dispatch(ctx, &cmd.UserListUpdateUser{
err := bus.Dispatch(ctx, &cmd.UserListUpdateUser{
Id: 1,
TenantId: 1,
Name: "Freddy",
})
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -175,11 +182,12 @@ func TestUpdateUser_EmailOnly(t *testing.T) {
env.Config.HostMode = "multi"
reset()

bus.Dispatch(ctx, &cmd.UserListUpdateUser{
err := bus.Dispatch(ctx, &cmd.UserListUpdateUser{
Id: 1,
TenantId: 1,
Email: "[email protected]",
})
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand All @@ -196,10 +204,11 @@ func TestMakeUserAdministrator(t *testing.T) {
env.Config.HostMode = "multi"
reset()

bus.Dispatch(ctx, &cmd.UserListHandleRoleChange{
err := bus.Dispatch(ctx, &cmd.UserListHandleRoleChange{
Id: 1,
Role: enum.RoleAdministrator,
})
Expect(err).IsNil()

Expect(httpclientmock.RequestsHistory).HasLen(1)

Expand Down

0 comments on commit c133eed

Please sign in to comment.