Skip to content

Commit 89aa834

Browse files
committed
rename types to typing
1 parent ee8ff4f commit 89aa834

File tree

5 files changed

+48
-48
lines changed

5 files changed

+48
-48
lines changed

component/component.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"unicode"
1717

1818
"github.com/gopherd/core/lifecycle"
19-
"github.com/gopherd/core/types"
19+
"github.com/gopherd/core/typing"
2020
)
2121

2222
// Config defines the configuration structure for creating a component.
@@ -28,22 +28,22 @@ type Config struct {
2828
UUID string `json:",omitempty"`
2929

3030
// Refs is the references to other components.
31-
Refs types.RawObject `json:",omitempty"`
31+
Refs typing.RawObject `json:",omitempty"`
3232

3333
// Options is the configuration options for the component.
34-
Options types.RawObject `json:",omitempty"`
34+
Options typing.RawObject `json:",omitempty"`
3535

3636
// TemplateUUID determines if the UUID should be templated.
3737
// If not set, the default value is determined by the service.
38-
TemplateUUID *types.Bool `json:",omitempty"`
38+
TemplateUUID *typing.Bool `json:",omitempty"`
3939

4040
// TemplateRefs determines if the Refs should be templated.
4141
// If not set, the default value is determined by the service.
42-
TemplateRefs *types.Bool `json:",omitempty"`
42+
TemplateRefs *typing.Bool `json:",omitempty"`
4343

4444
// TemplateOptions determines if the Options should be templated.
4545
// If not set, the default value is determined by the service.
46-
TemplateOptions *types.Bool `json:",omitempty"`
46+
TemplateOptions *typing.Bool `json:",omitempty"`
4747
}
4848

4949
// Component defines the interface for a generic logic component.

component/component_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/gopherd/core/component"
1515
"github.com/gopherd/core/op"
16-
"github.com/gopherd/core/types"
16+
"github.com/gopherd/core/typing"
1717
)
1818

1919
func TestMain(m *testing.M) {
@@ -139,11 +139,11 @@ func TestConfigMarshalUnmarshal(t *testing.T) {
139139
config: component.Config{
140140
Name: "TestComponent",
141141
UUID: "test-uuid",
142-
Refs: types.NewRawObject(`{"ref1":"uuid1"}`),
143-
Options: types.NewRawObject(`{"option1":"value1"}`),
144-
TemplateUUID: op.Addr(types.Bool(true)),
145-
TemplateRefs: op.Addr(types.Bool(false)),
146-
TemplateOptions: op.Addr(types.Bool(true)),
142+
Refs: typing.NewRawObject(`{"ref1":"uuid1"}`),
143+
Options: typing.NewRawObject(`{"option1":"value1"}`),
144+
TemplateUUID: op.Addr(typing.Bool(true)),
145+
TemplateRefs: op.Addr(typing.Bool(false)),
146+
TemplateOptions: op.Addr(typing.Bool(true)),
147147
},
148148
want: `{"Name":"TestComponent","UUID":"test-uuid","Refs":{"ref1":"uuid1"},"Options":{"option1":"value1"},"TemplateUUID":true,"TemplateRefs":false,"TemplateOptions":true}`,
149149
},
@@ -192,7 +192,7 @@ func TestBaseComponentSetup(t *testing.T) {
192192
config: component.Config{
193193
Name: "TestComponent",
194194
UUID: "test-uuid",
195-
Options: types.NewRawObject(`{"Value":"test"}`),
195+
Options: typing.NewRawObject(`{"Value":"test"}`),
196196
},
197197
wantErr: false,
198198
},
@@ -201,7 +201,7 @@ func TestBaseComponentSetup(t *testing.T) {
201201
config: component.Config{
202202
Name: "TestComponent",
203203
UUID: "test-uuid",
204-
Options: types.NewRawObject(`{"InvalidKey":"test"}`),
204+
Options: typing.NewRawObject(`{"InvalidKey":"test"}`),
205205
},
206206
wantErr: false,
207207
},
@@ -210,7 +210,7 @@ func TestBaseComponentSetup(t *testing.T) {
210210
config: component.Config{
211211
Name: "TestComponent",
212212
UUID: "test-uuid",
213-
Options: types.NewRawObject(`{invalid json`),
213+
Options: typing.NewRawObject(`{invalid json`),
214214
},
215215
wantErr: true,
216216
},
@@ -534,17 +534,17 @@ func TestRegisterAndCreate(t *testing.T) {
534534
func TestBoolPointerBehavior(t *testing.T) {
535535
tests := []struct {
536536
name string
537-
boolPtr *types.Bool
537+
boolPtr *typing.Bool
538538
wantJSON string
539539
}{
540540
{
541541
name: "True value",
542-
boolPtr: op.Addr(types.Bool(true)),
542+
boolPtr: op.Addr(typing.Bool(true)),
543543
wantJSON: "true",
544544
},
545545
{
546546
name: "False value",
547-
boolPtr: op.Addr(types.Bool(false)),
547+
boolPtr: op.Addr(typing.Bool(false)),
548548
wantJSON: "false",
549549
},
550550
{
@@ -565,7 +565,7 @@ func TestBoolPointerBehavior(t *testing.T) {
565565
t.Errorf("Marshaled JSON does not match expected.\nGot: %s\nWant: %s", string(data), tt.wantJSON)
566566
}
567567

568-
var unmarshaled *types.Bool
568+
var unmarshaled *typing.Bool
569569
err = json.Unmarshal(data, &unmarshaled)
570570
if err != nil {
571571
t.Fatalf("Failed to unmarshal bool pointer: %v", err)
@@ -596,7 +596,7 @@ func ExampleBaseComponent() {
596596
config := component.Config{
597597
Name: "ExampleComponent",
598598
UUID: "example-uuid",
599-
Options: types.NewRawObject(`{"Value":"example"}`),
599+
Options: typing.NewRawObject(`{"Value":"example"}`),
600600
}
601601

602602
err := mc.Setup(container, &config, false)
@@ -665,7 +665,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
665665
config := component.Config{
666666
Name: "TestComponentWithRefs",
667667
UUID: "test-uuid",
668-
Refs: types.NewRawObject(`{"Ref1":"ref1","Ref2":"ref2"}`),
668+
Refs: typing.NewRawObject(`{"Ref1":"ref1","Ref2":"ref2"}`),
669669
}
670670

671671
err := tc.Setup(container, &config, false)
@@ -686,7 +686,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
686686
config := component.Config{
687687
Name: "TestComponentWithRefs",
688688
UUID: "test-uuid",
689-
Refs: types.NewRawObject(`{invalid json`),
689+
Refs: typing.NewRawObject(`{invalid json`),
690690
}
691691
err := tc.Setup(container, &config, false)
692692
if err == nil || !strings.Contains(err.Error(), "failed to unmarshal refs") {
@@ -702,7 +702,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
702702
config := component.Config{
703703
Name: "TestComponentWithRefs",
704704
UUID: "test-uuid",
705-
Refs: types.NewRawObject(`{"Ref1":"non-existent-uuid"}`),
705+
Refs: typing.NewRawObject(`{"Ref1":"non-existent-uuid"}`),
706706
}
707707
err := tc.Setup(mockContainer, &config, false)
708708
if err == nil || !strings.Contains(err.Error(), "failed to resolve reference") {
@@ -730,7 +730,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
730730
config := component.Config{
731731
Name: "NestedComponent",
732732
UUID: "nested-uuid",
733-
Refs: types.NewRawObject(`{"Ref1":"ref1","NestedStruct":{"Ref2":"ref2"}}`),
733+
Refs: typing.NewRawObject(`{"Ref1":"ref1","NestedStruct":{"Ref2":"ref2"}}`),
734734
}
735735

736736
err := nc.Setup(container, &config, false)
@@ -775,7 +775,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
775775
config := component.Config{
776776
Name: "MixedComponent",
777777
UUID: "mixed-uuid",
778-
Refs: types.NewRawObject(`{"Ref1":"ref1","Ref2":null,"Ref3":{},"Ref4":"not-a-ref","X":{"Ref5":"ref1"},"Y":{"Ref6":"ref1"},"Ref7":["ref1","ref1"],"Ref8":["ref1"],"Ref9":{"key":"ref1"}}`),
778+
Refs: typing.NewRawObject(`{"Ref1":"ref1","Ref2":null,"Ref3":{},"Ref4":"not-a-ref","X":{"Ref5":"ref1"},"Y":{"Ref6":"ref1"},"Ref7":["ref1","ref1"],"Ref8":["ref1"],"Ref9":{"key":"ref1"}}`),
779779
}
780780

781781
err := mixedComp.Setup(container, &config, false)
@@ -833,7 +833,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
833833
config := component.Config{
834834
Name: "TestComponentWithRefs",
835835
UUID: "test-uuid",
836-
Refs: types.NewRawObject(`{invalid json`),
836+
Refs: typing.NewRawObject(`{invalid json`),
837837
}
838838
err := tc.Setup(newMockContainer(), &config, false)
839839
if err == nil || !strings.Contains(err.Error(), "failed to unmarshal refs") {
@@ -846,7 +846,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
846846
config := component.Config{
847847
Name: "NonStructRefs",
848848
UUID: "non-struct-uuid",
849-
Refs: types.NewRawObject(`"string ref"`),
849+
Refs: typing.NewRawObject(`"string ref"`),
850850
}
851851
err := cnsr.Setup(newMockContainer(), &config, false)
852852
if err != nil {
@@ -867,7 +867,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
867867
config := component.Config{
868868
Name: "DeepRefs",
869869
UUID: "deep-refs-uuid",
870-
Refs: types.NewRawObject(`{
870+
Refs: typing.NewRawObject(`{
871871
"Ref1": "ref1",
872872
"Nested": {
873873
"Ref2": "ref2",
@@ -905,7 +905,7 @@ func TestBaseComponentWithRefs(t *testing.T) {
905905
config := component.Config{
906906
Name: "FailingResolver",
907907
UUID: "failing-resolver-uuid",
908-
Refs: types.NewRawObject(`{"FailingRef": "some-uuid"}`),
908+
Refs: typing.NewRawObject(`{"FailingRef": "some-uuid"}`),
909909
}
910910

911911
err := cfr.Setup(newMockContainer(), &config, false)

service/config_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/gopherd/core/component"
1818
"github.com/gopherd/core/encoding"
1919
"github.com/gopherd/core/op"
20-
"github.com/gopherd/core/types"
20+
"github.com/gopherd/core/typing"
2121
)
2222

2323
type TestContext struct {
@@ -268,14 +268,14 @@ func TestConfig_ProcessTemplate(t *testing.T) {
268268
{
269269
Name: "Component1",
270270
UUID: "{{.Name}}-UUID",
271-
TemplateUUID: op.Addr(types.Bool(true)),
272-
TemplateRefs: op.Addr(types.Bool(true)),
273-
TemplateOptions: op.Addr(types.Bool(true)),
274-
Refs: types.NewRawObject(op.MustResult(json.Marshal(refs{
271+
TemplateUUID: op.Addr(typing.Bool(true)),
272+
TemplateRefs: op.Addr(typing.Bool(true)),
273+
TemplateOptions: op.Addr(typing.Bool(true)),
274+
Refs: typing.NewRawObject(op.MustResult(json.Marshal(refs{
275275
A: "{{.Name}}-A",
276276
B: "B",
277277
}))),
278-
Options: types.NewRawObject(op.MustResult(json.Marshal(options{
278+
Options: typing.NewRawObject(op.MustResult(json.Marshal(options{
279279
C: "C",
280280
D: "{{.Name}}-D",
281281
}))),
@@ -291,14 +291,14 @@ func TestConfig_ProcessTemplate(t *testing.T) {
291291
{
292292
Name: "Component1",
293293
UUID: "TestName-UUID",
294-
TemplateUUID: op.Addr(types.Bool(true)),
295-
TemplateRefs: op.Addr(types.Bool(true)),
296-
TemplateOptions: op.Addr(types.Bool(true)),
297-
Refs: types.NewRawObject(op.MustResult(json.Marshal(refs{
294+
TemplateUUID: op.Addr(typing.Bool(true)),
295+
TemplateRefs: op.Addr(typing.Bool(true)),
296+
TemplateOptions: op.Addr(typing.Bool(true)),
297+
Refs: typing.NewRawObject(op.MustResult(json.Marshal(refs{
298298
A: "TestName-A",
299299
B: "B",
300300
}))),
301-
Options: types.NewRawObject(op.MustResult(json.Marshal(options{
301+
Options: typing.NewRawObject(op.MustResult(json.Marshal(options{
302302
C: "C",
303303
D: "TestName-D",
304304
}))),
@@ -338,7 +338,7 @@ func TestConfig_ProcessTemplate(t *testing.T) {
338338
{
339339
Name: "Component1",
340340
UUID: "{{.NameXXX}}-UUID",
341-
TemplateUUID: op.Addr(types.Bool(true)),
341+
TemplateUUID: op.Addr(typing.Bool(true)),
342342
},
343343
},
344344
},
@@ -353,8 +353,8 @@ func TestConfig_ProcessTemplate(t *testing.T) {
353353
Components: []component.Config{
354354
{
355355
Name: "Component1",
356-
TemplateRefs: op.Addr(types.Bool(true)),
357-
Refs: types.NewRawObject(op.MustResult(json.Marshal(map[string]string{
356+
TemplateRefs: op.Addr(typing.Bool(true)),
357+
Refs: typing.NewRawObject(op.MustResult(json.Marshal(map[string]string{
358358
"A": "{{.NameXXX}}-A",
359359
"B": "B",
360360
}))),
@@ -372,8 +372,8 @@ func TestConfig_ProcessTemplate(t *testing.T) {
372372
Components: []component.Config{
373373
{
374374
Name: "Component1",
375-
TemplateOptions: op.Addr(types.Bool(true)),
376-
Options: types.NewRawObject(op.MustResult(json.Marshal(map[string]string{
375+
TemplateOptions: op.Addr(typing.Bool(true)),
376+
Options: typing.NewRawObject(op.MustResult(json.Marshal(map[string]string{
377377
"A": "{{.NameXXX}}-A",
378378
"B": "B",
379379
}))),

types/types.go renamed to typing/typing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Package types provides utilities for handling raw data objects and
1+
// Package typing provides utilities for handling raw data objects and
22
// wraps basic Go types with additional functionality. It offers tools
33
// for flexible data processing and enhanced type manipulation, useful
44
// in various data handling and parsing scenarios.
5-
package types
5+
package typing
66

77
import (
88
"encoding/base64"

types/types_test.go renamed to typing/typing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package types
1+
package typing
22

33
import (
44
"encoding/base64"

0 commit comments

Comments
 (0)