(x *testing.T)
| 44 | } |
| 45 | |
| 46 | func TestGroupCache(x *testing.T) { |
| 47 | t := openTopom() |
| 48 | defer t.Close() |
| 49 | |
| 50 | const gid = 100 |
| 51 | |
| 52 | check := func(exists bool, state string) { |
| 53 | ctx, err := t.newContext() |
| 54 | assert.MustNoError(err) |
| 55 | if !exists { |
| 56 | assert.Must(ctx.group[gid] == nil) |
| 57 | } else { |
| 58 | g, err := ctx.getGroup(gid) |
| 59 | assert.MustNoError(err) |
| 60 | assert.Must(g.Id == gid && g.Promoting.State == state) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | g := &models.Group{Id: gid} |
| 65 | check(false, "") |
| 66 | |
| 67 | t.dirtyGroupCache(gid) |
| 68 | check(false, "") |
| 69 | |
| 70 | t.dirtyGroupCache(gid) |
| 71 | assert.MustNoError(t.storeCreateGroup(g)) |
| 72 | check(true, models.ActionNothing) |
| 73 | |
| 74 | t.dirtyGroupCache(gid) |
| 75 | g.Promoting.State = models.ActionPreparing |
| 76 | check(true, models.ActionNothing) |
| 77 | |
| 78 | t.dirtyGroupCache(gid) |
| 79 | g.Promoting.State = models.ActionPreparing |
| 80 | assert.MustNoError(t.storeUpdateGroup(g)) |
| 81 | check(true, models.ActionPreparing) |
| 82 | |
| 83 | t.dirtyCacheAll() |
| 84 | g.Promoting.State = models.ActionPrepared |
| 85 | assert.MustNoError(t.storeUpdateGroup(g)) |
| 86 | check(true, models.ActionPrepared) |
| 87 | |
| 88 | t.dirtyGroupCache(gid) |
| 89 | assert.MustNoError(t.storeRemoveGroup(g)) |
| 90 | check(false, "") |
| 91 | } |
| 92 | |
| 93 | func TestProxyCache(x *testing.T) { |
| 94 | t := openTopom() |
nothing calls this directly
no test coverage detected