23 lines
582 B
Go
23 lines
582 B
Go
package run
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestNodeViewDoesNotExposeInternalSnapshotFields(t *testing.T) {
|
|
raw, err := json.Marshal(NodeView{NodeKey: "stage", Type: "stage", Title: "知识", Content: "内容"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var value map[string]interface{}
|
|
if err := json.Unmarshal(raw, &value); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, key := range []string{"id", "tenant_id", "sop_id", "config", "position_x", "position_y"} {
|
|
if _, exists := value[key]; exists {
|
|
t.Fatalf("public node contains internal field %s: %s", key, raw)
|
|
}
|
|
}
|
|
}
|