MCPcopy Index your code
hub / github.com/koding/kite / TestScrubUnscrub

Function TestScrubUnscrub

dnode/scrubber_test.go:5–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestScrubUnscrub(t *testing.T) {
6 scrubber := NewScrubber()
7
8 type Args struct {
9 A int
10 B string
11 C Function
12 }
13
14 obj := Args{
15 A: 1,
16 B: "foo",
17 C: Callback(func(*Partial) {}),
18 }
19
20 callbacks := scrubber.Scrub(obj)
21 t.Logf("callbacks: %+q\n", callbacks)
22
23 args := Args{
24 A: 2,
25 B: "bar",
26 }
27
28 var sent bool
29 sendf := func(id uint64) functionReceived {
30 return func(args ...interface{}) error {
31 sent = true
32 return nil
33 }
34 }
35
36 scrubber.Unscrub(&args, callbacks, sendf)
37 t.Logf("args: %+v\n", args)
38
39 if args.C.Caller == nil {
40 t.Fatal("callback is not set")
41 }
42
43 if err := args.C.Call(); err != nil {
44 t.Error(err)
45 }
46
47 if !sent {
48 t.Error("callback is not called")
49 }
50}

Callers

nothing calls this directly

Calls 7

ScrubMethod · 0.95
UnscrubMethod · 0.95
NewScrubberFunction · 0.85
FatalMethod · 0.80
CallbackFunction · 0.70
CallMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected