Skip to content

Commit 1bb86be

Browse files
authored
chore(server): remaining ID refactoring [VIZ-574] (#1517)
1 parent e8a438c commit 1bb86be

File tree

129 files changed

+1271
-1265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1271
-1265
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ node_modules
55
/.env
66
/.env.*
77
/.idea
8+
9+
server/test.log

server/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ help:
1212
@echo "Targets:"
1313
@echo " lint Run golangci-lint with auto-fix"
1414
@echo " test Run unit tests with race detector in short mode"
15-
@echo " failcheck Run unit tests with fail-fast and no parallel execution"
15+
@echo " test-debug Run unit tests with outpt log"
1616
@echo " e2e Run end-to-end tests"
1717
@echo " build Build the project"
1818
@echo " dev-install Install tools for make dev - behavior not confirmed in windows."
@@ -34,8 +34,8 @@ REEARTH_DB := mongodb://localhost
3434
test:
3535
REEARTH_DB=${REEARTH_DB} go test ./... -run ${TARGET_TEST}
3636

37-
failcheck:
38-
go test -race -short -failfast -p 1 $(TEST_DIR)
37+
test-debug:
38+
go test -v -timeout 10s ./... | tee test.log
3939

4040
e2e:
4141
go test -v ./e2e/...
@@ -109,4 +109,4 @@ schematyper:
109109
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_translation.go --package manifest --prefix Translation ./schemas/plugin_manifest_translation.json
110110
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_gen.go --package manifest ./schemas/plugin_manifest.json
111111

112-
.PHONY: lint test failcheck e2e build dev-install dev run-app run-db run-reset gql up-gcs down-gcs mockuser schematyper
112+
.PHONY: lint test test-debug e2e build dev-install dev run-app run-db run-reset gql up-gcs down-gcs mockuser schematyper

server/e2e/seeder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ var (
4545
sID = id.NewSceneID()
4646
now = time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
4747

48-
storyID = storytelling.NewStoryID()
49-
pageID = storytelling.NewPageID()
50-
blockID = storytelling.NewBlockID()
48+
storyID = id.NewStoryID()
49+
pageID = id.NewPageID()
50+
blockID = id.NewBlockID()
5151
)
5252

5353
func baseSeeder(ctx context.Context, r *repo.Container, f gateway.File) error {
@@ -455,7 +455,7 @@ func addGeoJson(layerID nlslayer.ID, ctx context.Context, r *repo.Container) err
455455
}
456456

457457
feature, err := nlslayer.NewFeature(
458-
nlslayer.NewFeatureID(),
458+
id.NewFeatureID(),
459459
"Feature",
460460
geometry,
461461
)

server/internal/adapter/gql/gqlmodel/convert_nlslayer_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package gqlmodel
33
import (
44
"testing"
55

6+
"github.com/reearth/reearth/server/pkg/id"
67
"github.com/reearth/reearth/server/pkg/nlslayer"
78
"github.com/stretchr/testify/assert"
89
)
910

1011
func TestToNLSLayerSketchInfo(t *testing.T) {
1112
feature1, err := nlslayer.NewFeature(
12-
nlslayer.NewFeatureID(),
13+
id.NewFeatureID(),
1314
"Feature",
1415
nlslayer.NewPoint("Point", []float64{1, 2}),
1516
)
@@ -19,7 +20,7 @@ func TestToNLSLayerSketchInfo(t *testing.T) {
1920
feature1.UpdateProperties(&map[string]any{"key1": "value1"})
2021

2122
feature2, err := nlslayer.NewFeature(
22-
nlslayer.NewFeatureID(),
23+
id.NewFeatureID(),
2324
"Feature",
2425
nlslayer.NewLineString("LineString", [][]float64{{1, 2}, {3, 4}}),
2526
)
@@ -29,7 +30,7 @@ func TestToNLSLayerSketchInfo(t *testing.T) {
2930
feature2.UpdateProperties(&map[string]any{"key2": "value2"})
3031

3132
feature3, err := nlslayer.NewFeature(
32-
nlslayer.NewFeatureID(),
33+
id.NewFeatureID(),
3334
"Feature",
3435
nlslayer.NewPolygon("Polygon", [][][]float64{{{1, 2}, {3, 4}, {5, 6}, {1, 2}}}),
3536
)
@@ -39,7 +40,7 @@ func TestToNLSLayerSketchInfo(t *testing.T) {
3940
feature3.UpdateProperties(&map[string]any{"key3": "value3"})
4041

4142
feature4, err := nlslayer.NewFeature(
42-
nlslayer.NewFeatureID(),
43+
id.NewFeatureID(),
4344
"Feature",
4445
nlslayer.NewMultiPolygon("MultiPolygon", [][][][]float64{{{{1, 2}, {3, 4}, {5, 6}, {1, 2}}}}),
4546
)
@@ -49,7 +50,7 @@ func TestToNLSLayerSketchInfo(t *testing.T) {
4950
feature4.UpdateProperties(&map[string]any{"key4": "value4"})
5051

5152
feature5, err := nlslayer.NewFeature(
52-
nlslayer.NewFeatureID(),
53+
id.NewFeatureID(),
5354
"Feature",
5455
nlslayer.NewGeometryCollection(
5556
"GeometryCollection",

server/internal/adapter/gql/gqlmodel/convert_property.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func ToMergedPropertyField(f *property.MergedField, s id.PropertySchemaID) *Merg
399399
}
400400
}
401401

402-
func ToPropertySchemaGroup(g *property.SchemaGroup, s property.SchemaID) *PropertySchemaGroup {
402+
func ToPropertySchemaGroup(g *property.SchemaGroup, s id.PropertySchemaID) *PropertySchemaGroup {
403403
if g == nil {
404404
return nil
405405
}

server/internal/infrastructure/fs/plugin_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/reearth/reearth/server/pkg/i18n"
8+
"github.com/reearth/reearth/server/pkg/id"
89
"github.com/reearth/reearth/server/pkg/plugin"
910
"github.com/spf13/afero"
1011
"github.com/stretchr/testify/assert"
@@ -13,9 +14,9 @@ import (
1314
func TestPlugin(t *testing.T) {
1415
ctx := context.Background()
1516
fs := NewPlugin(mockPluginFS())
16-
p, err := fs.FindByID(ctx, plugin.MustID("testplugin~1.0.0"))
17+
p, err := fs.FindByID(ctx, id.MustPluginID("testplugin~1.0.0"))
1718
assert.NoError(t, err)
18-
assert.Equal(t, plugin.New().ID(plugin.MustID("testplugin~1.0.0")).Name(i18n.String{
19+
assert.Equal(t, plugin.New().ID(id.MustPluginID("testplugin~1.0.0")).Name(i18n.String{
1920
"en": "testplugin",
2021
"ja": "テストプラグイン",
2122
"zh-CN": "测试插件",

server/internal/infrastructure/mongo/migration/221028204300_move_terrain_properties.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/reearth/reearth/server/internal/infrastructure/mongo/mongodoc"
7+
"github.com/reearth/reearth/server/pkg/id"
78
"github.com/reearth/reearth/server/pkg/property"
89
"github.com/reearth/reearthx/log"
910
"github.com/reearth/reearthx/mongox"
@@ -13,7 +14,7 @@ import (
1314

1415
func MoveTerrainProperties(ctx context.Context, c DBClient) error {
1516
col := c.WithCollection("property")
16-
fields := []property.FieldID{
17+
fields := []id.PropertyFieldID{
1718
"terrain",
1819
"terrainType",
1920
"terrainExaggeration",
@@ -22,7 +23,7 @@ func MoveTerrainProperties(ctx context.Context, c DBClient) error {
2223
}
2324

2425
diff := property.SchemaDiff{
25-
Moved: lo.Map(fields, func(f property.FieldID, _ int) property.SchemaDiffMoved {
26+
Moved: lo.Map(fields, func(f id.PropertyFieldID, _ int) property.SchemaDiffMoved {
2627
return property.SchemaDiffMoved{
2728
From: property.SchemaFieldPointer{
2829
SchemaGroup: "default",

server/internal/infrastructure/mongo/mongodoc/nlslayer_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package mongodoc
33
import (
44
"testing"
55

6+
"github.com/reearth/reearth/server/pkg/id"
67
"github.com/reearth/reearth/server/pkg/nlslayer"
78
"github.com/stretchr/testify/assert"
89
"go.mongodb.org/mongo-driver/bson/primitive"
910
)
1011

1112
func TestToModelNLSLayerSketchInfo(t *testing.T) {
12-
fid := nlslayer.NewFeatureID()
13+
fid := id.NewFeatureID()
1314
property := map[string]any{"key1": "value1"}
1415
f, err := nlslayer.NewFeature(
1516
fid,
@@ -233,7 +234,7 @@ func TestToModelNLSLayerGeometry(t *testing.T) {
233234
}
234235

235236
func TestNewNLSLayerSketchInfo(t *testing.T) {
236-
fid := nlslayer.NewFeatureID()
237+
fid := id.NewFeatureID()
237238
property := map[string]any{"key1": "value1"}
238239
f, err := nlslayer.NewFeature(
239240
fid,
@@ -273,7 +274,7 @@ func TestNewNLSLayerSketchInfo(t *testing.T) {
273274
}
274275

275276
func TestNewNLSLayerFeatureCollection(t *testing.T) {
276-
fid := nlslayer.NewFeatureID()
277+
fid := id.NewFeatureID()
277278
property := map[string]any{"key1": "value1"}
278279
f, err := nlslayer.NewFeature(
279280
fid,
@@ -305,7 +306,7 @@ func TestNewNLSLayerFeatureCollection(t *testing.T) {
305306
}
306307

307308
func TestNewNLSLayerFeature(t *testing.T) {
308-
fid := nlslayer.NewFeatureID()
309+
fid := id.NewFeatureID()
309310
property := map[string]any{"key1": "value1"}
310311
f, err := nlslayer.NewFeature(
311312
fid,

server/internal/infrastructure/mongo/mongodoc/property.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func toModelPropertyField(f *PropertyFieldDocument) *property.Field {
171171
}
172172

173173
vt := property.ValueType(f.Type)
174-
field := property.NewField(property.FieldID(f.Field)).
174+
field := property.NewField(id.PropertyFieldID(f.Field)).
175175
Value(property.NewOptionalValue(vt, toModelPropertyValue(f.Value, f.Type))).
176176
Build()
177177

server/internal/infrastructure/mongo/mongodoc/property_schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ func toModelPropertyPointer(p *PropertySchemaFieldPointerDocument) *property.Sch
293293
return nil
294294
}
295295
return &property.SchemaFieldPointer{
296-
SchemaGroup: property.SchemaGroupID(p.SchemaGroupID),
297-
Field: property.FieldID(p.FieldID),
296+
SchemaGroup: id.PropertySchemaGroupID(p.SchemaGroupID),
297+
Field: id.PropertyFieldID(p.FieldID),
298298
}
299299
}
300300

0 commit comments

Comments
 (0)