forked from andersfylling/disgord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache_test.go
49 lines (39 loc) · 1.11 KB
/
cache_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package disgord
import "testing"
func TestCache_ChannelCreate(t *testing.T) {
t.Run("immutable", func(t *testing.T) {
cache, _ := newCache(&CacheConfig{
ChannelCacheAlgorithm: CacheAlgLRU,
DisableGuildCaching: true,
DisableUserCaching: true,
DisableVoiceStateCaching: true,
})
c1 := NewChannel()
c1.ID = Snowflake(1234123)
cache.SetChannel(c1)
c1.ID = Snowflake(4537345435)
if r, err := cache.GetChannel(Snowflake(1234123)); r.ID != Snowflake(1234123) || err != nil {
t.Error(err)
t.Error("error with retrieving channel")
}
})
t.Run("mutable", func(t *testing.T) {
cache, _ := newCache(&CacheConfig{
Mutable: true,
ChannelCacheAlgorithm: CacheAlgLRU,
DisableGuildCaching: true,
DisableUserCaching: true,
DisableVoiceStateCaching: true,
})
c1 := NewChannel()
c1.ID = Snowflake(1234123)
test := "test"
c1.Icon = &test
cache.SetChannel(c1)
changed := "changed"
c1.Icon = &changed
if r, _ := cache.GetChannel(c1.ID); *r.Icon != "changed" {
t.Error("channel was not affected by external changes")
}
})
}