MCPcopy Create free account
hub / github.com/golobby/container / TestContainer_Singleton

Function TestContainer_Singleton

container_test.go:40–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38var instance = container.New()
39
40func TestContainer_Singleton(t *testing.T) {
41 err := instance.Singleton(func() Shape {
42 return &Circle{a: 13}
43 })
44 assert.NoError(t, err)
45
46 err = instance.Call(func(s1 Shape) {
47 s1.SetArea(666)
48 })
49 assert.NoError(t, err)
50
51 err = instance.Call(func(s2 Shape) {
52 a := s2.GetArea()
53 assert.Equal(t, a, 666)
54 })
55 assert.NoError(t, err)
56}
57
58func TestContainer_SingletonLazy(t *testing.T) {
59 err := instance.SingletonLazy(func() Shape {

Callers

nothing calls this directly

Calls 4

SingletonMethod · 0.80
CallMethod · 0.80
SetAreaMethod · 0.65
GetAreaMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…