Skip to content

Commit f34b7c3

Browse files
committed
close #120: private state
1 parent 078ee68 commit f34b7c3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

helpers/components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ComponentSerialize(component interface{}) string {
4545
if cmap, ok := component.(map[string]interface{}); ok {
4646
_component := map[string]interface{}{}
4747
for k, v := range cmap {
48-
if !strings.HasPrefix(k, "internal:") {
48+
if !strings.HasPrefix(k, "internal:") && !strings.HasPrefix(k, "private:") {
4949
_component[k] = v
5050
}
5151
}

helpers/components_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ func TestComponentSerialize(t *testing.T) {
5555
"internal:name": "testcomponent",
5656
}
5757
obj2 := map[string]interface{}{
58+
"private:name": "testcomponent",
59+
}
60+
obj3 := map[string]interface{}{
5861
"Foo": "Bar",
5962
}
6063
// Check serialization
6164
if ComponentSerialize(obj1) == "eyJpbnRlcm5hbDpuYW1lIjoidGVzdGNvbXBvbmVudCJ9" {
6265
t.Error("ComponentSerialize is not clearing internal variables")
6366
}
64-
if ComponentSerialize(obj2) != "eyJGb28iOiJCYXIifQ==" {
67+
if ComponentSerialize(obj2) == "eyJwcml2YXRlOm5hbWUiOiJ0ZXN0Y29tcG9uZW50In0=" {
68+
t.Error("ComponentSerialize is not clearing internal variables")
69+
}
70+
if ComponentSerialize(obj3) != "eyJGb28iOiJCYXIifQ==" {
6571
t.Error("ComponentSerialize is not working correctly")
6672
}
6773
}

0 commit comments

Comments
 (0)