MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / TestFunctionSerde

Function TestFunctionSerde

common/model/function_serde_test.go:28–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestFunctionSerde(t *testing.T) {
29 f := Function{
30 Name: "TestFunction",
31 Runtime: RuntimeConfig{Type: "runtime", Config: map[string]interface{}{"key": "value"}},
32 Sources: []TubeConfig{{Type: "source", Config: map[string]interface{}{"key": "value"}}},
33 Sink: TubeConfig{Type: "sink", Config: map[string]interface{}{"key": "value"}},
34 Config: map[string]string{"key": "value"},
35 Replicas: 2,
36 }
37
38 // JSON Serialization
39 data, err := json.Marshal(f)
40 if err != nil {
41 t.Fatal("JSON Serialization error:", err)
42 }
43
44 fmt.Println(string(data))
45
46 // JSON Deserialization
47 var f2 Function
48 err = json.Unmarshal(data, &f2)
49 if err != nil {
50 t.Fatal("JSON Deserialization error:", err)
51 }
52
53 if !reflect.DeepEqual(f, f2) {
54 t.Error("JSON Deserialization does not match original")
55 }
56
57 // YAML Serialization
58 data, err = yaml.Marshal(f)
59 if err != nil {
60 t.Fatal("YAML Serialization error:", err)
61 }
62
63 fmt.Println(string(data))
64
65 // YAML Deserialization
66 err = yaml.Unmarshal(data, &f2)
67 if err != nil {
68 t.Fatal("YAML Deserialization error:", err)
69 }
70
71 if !reflect.DeepEqual(f, f2) {
72 t.Error("YAML Deserialization does not match original")
73 }
74}
75
76func TestFunctionSerdeWithNil(t *testing.T) {
77 f := Function{

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected