| 92 | } |
| 93 | |
| 94 | func TestIsAppKey(t *testing.T) { |
| 95 | tests := []struct { |
| 96 | key string |
| 97 | expected bool |
| 98 | }{ |
| 99 | {"app:setting1", true}, |
| 100 | {"app:", false}, // 长度不够 |
| 101 | {"user:setting1", false}, |
| 102 | {"temp:setting1", false}, |
| 103 | {"session:setting1", false}, |
| 104 | {"setting1", false}, |
| 105 | } |
| 106 | |
| 107 | for _, tt := range tests { |
| 108 | t.Run(tt.key, func(t *testing.T) { |
| 109 | result := IsAppKey(tt.key) |
| 110 | if result != tt.expected { |
| 111 | t.Errorf("IsAppKey(%q) = %v, expected %v", tt.key, result, tt.expected) |
| 112 | } |
| 113 | }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | func TestIsUserKey(t *testing.T) { |
| 118 | tests := []struct { |