-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_test.go
More file actions
53 lines (48 loc) · 1.44 KB
/
cache_test.go
File metadata and controls
53 lines (48 loc) · 1.44 KB
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
50
51
52
53
package QueryHelper
import (
"context"
"github.com/Seann-Moser/ctx_cache"
"testing"
)
type AccountUserRole struct {
AccountID string `json:"account_id" db:"account_id" qc:"primary;join;join_name::account_id"`
UserID string `json:"user_id" db:"user_id" qc:"primary;varchar(512);"`
RoleID string `json:"role_id" db:"role_id" qc:"primary;join;foreign_key::id;foreign_table::role"`
UpdatedTimestamp string `json:"updated_timestamp" db:"updated_timestamp" qc:"skip;default::updated_timestamp"`
CreatedTimestamp string `json:"created_timestamp" db:"created_timestamp" qc:"skip;default::created_timestamp"`
}
func TestCacheTest(t *testing.T) {
ctx := context.Background()
go ctx_cache.GlobalCacheMonitor.Start(ctx)
table, err := NewTable[AccountUserRole]("test", "")
if err != nil {
t.Fatal(err.Error())
}
q := QueryTable[AccountUserRole](table)
//if !isSuperAdmin {
q.Where(q.Column("user_id"), "=", "AND", 0, "")
q.UseCache()
q.SetName("rbac-accounts-for-user")
_, err = q.Run(ctx, nil)
if err != nil {
t.Error(err.Error())
}
aur := &AccountUserRole{
AccountID: "",
UserID: "",
RoleID: "",
}
_, err = table.Insert(ctx, nil, *aur)
if err != nil {
t.Error(err.Error())
}
qt := QueryTable[AccountUserRole](table)
//if !isSuperAdmin {
qt.Where(q.Column("user_id"), "=", "AND", 0, "")
qt.UseCache()
qt.SetName("rbac-accounts-for-user")
_, err = qt.Run(ctx, nil)
if err != nil {
t.Error(err.Error())
}
}