Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaforce committed Nov 21, 2024
1 parent 78f7e15 commit 7eed562
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "3"
services:
reearth:
image: reearth/reearth-visualizer:latest
Expand Down
9 changes: 1 addition & 8 deletions server/internal/adapter/gql/loader_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gql

import (
"context"
"errors"

"github.com/reearth/reearth/server/internal/adapter/gql/gqldataloader"
"github.com/reearth/reearth/server/internal/adapter/gql/gqlmodel"
Expand Down Expand Up @@ -44,13 +43,7 @@ func (c *UserLoader) SearchUser(ctx context.Context, nameOrEmail string) (*gqlmo
return nil, err
}

for _, user := range res {
if user.Name == nameOrEmail || user.Email == nameOrEmail {
return gqlmodel.ToUserFromSimple(user), nil
}
}

return nil, errors.New("user not found.")
return gqlmodel.ToUserFromSimple(res), nil
}

// data loader
Expand Down
39 changes: 35 additions & 4 deletions server/internal/infrastructure/mongo/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ func TestProject_FindStarredByWorkspace(t *testing.T) {
pid2 := id.NewProjectID()
pid3 := id.NewProjectID()
pid4 := id.NewProjectID()
pid5 := id.NewProjectID()

_, _ = c.Collection("project").InsertMany(ctx, []any{
bson.M{"id": pid1.String(), "team": wid.String(), "name": "Project 1", "starred": true},
bson.M{"id": pid2.String(), "team": wid.String(), "name": "Project 2", "starred": true},
bson.M{"id": pid3.String(), "team": wid.String(), "name": "Project 3", "starred": false},
bson.M{"id": pid4.String(), "team": wid2.String(), "name": "Project 4", "starred": true},
bson.M{"id": pid1.String(), "team": wid.String(), "name": "Project 1", "starred": true, "coresupport": true},
bson.M{"id": pid2.String(), "team": wid.String(), "name": "Project 2", "starred": true, "coresupport": true},
bson.M{"id": pid3.String(), "team": wid.String(), "name": "Project 3", "starred": false, "coresupport": true},
bson.M{"id": pid4.String(), "team": wid2.String(), "name": "Project 4", "starred": true, "coresupport": true},
bson.M{"id": pid5.String(), "team": wid2.String(), "name": "Project 5", "starred": true, "coresupport": false},
})

r := NewProject(mongox.NewClientWithDatabase(c))
Expand Down Expand Up @@ -191,3 +193,32 @@ func TestProject_FindStarredByWorkspace(t *testing.T) {
assert.Empty(t, got)
})
}

func TestProject_FindDeletedByWorkspace(t *testing.T) {
c := mongotest.Connect(t)(t)
ctx := context.Background()

wid := accountdomain.NewWorkspaceID()
wid2 := accountdomain.NewWorkspaceID()

pid1 := id.NewProjectID()
pid2 := id.NewProjectID()
pid3 := id.NewProjectID()
pid4 := id.NewProjectID()

_, _ = c.Collection("project").InsertMany(ctx, []any{
bson.M{"id": pid1.String(), "team": wid.String(), "name": "Project 1", "deleted": false, "coresupport": true},
bson.M{"id": pid2.String(), "team": wid.String(), "name": "Project 2", "deleted": true, "coresupport": true},
bson.M{"id": pid3.String(), "team": wid2.String(), "name": "Project 3", "deleted": false, "coresupport": true},
bson.M{"id": pid4.String(), "team": wid2.String(), "name": "Project 4", "deleted": true, "coresupport": true},
})

r := NewProject(mongox.NewClientWithDatabase(c))

t.Run("FindDeletedByWorkspace", func(t *testing.T) {
got, err := r.FindDeletedByWorkspace(ctx, wid)
assert.NoError(t, err)
assert.Equal(t, 1, len(got))
})

}

0 comments on commit 7eed562

Please sign in to comment.