@@ -2,6 +2,7 @@ package caveats
2
2
3
3
import (
4
4
"testing"
5
+ "time"
5
6
6
7
"github.com/stretchr/testify/require"
7
8
@@ -10,6 +11,8 @@ import (
10
11
core "github.com/authzed/spicedb/pkg/proto/core/v1"
11
12
)
12
13
14
+ var testTime = time .Date (2021 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )
15
+
13
16
func TestBuildDebugInformation (t * testing.T ) {
14
17
tcs := []struct {
15
18
name string
@@ -165,6 +168,26 @@ func TestBuildDebugInformation(t *testing.T) {
165
168
},
166
169
expectedExprString : "(a__0 + b__0 + c == 5) && (a__1 - b__1 - d == 64)" ,
167
170
},
171
+ {
172
+ name : "name reuse around times" ,
173
+ result : and (
174
+ eval ("expires_at < now" , map [string ]any {
175
+ "expires_at" : testTime ,
176
+ "now" : testTime .Add (1 * time .Hour ),
177
+ }),
178
+ eval ("expires_at < now" , map [string ]any {
179
+ "expires_at" : testTime ,
180
+ "now" : testTime .Add (1 * time .Hour ),
181
+ }),
182
+ ),
183
+ expectedContext : map [string ]any {
184
+ "expires_at__0" : "2021-01-01T00:00:00Z" ,
185
+ "expires_at__1" : "2021-01-01T00:00:00Z" ,
186
+ "now__0" : "2021-01-01T01:00:00Z" ,
187
+ "now__1" : "2021-01-01T01:00:00Z" ,
188
+ },
189
+ expectedExprString : "(expires_at__0 < now__0) && (expires_at__1 < now__1)" ,
190
+ },
168
191
}
169
192
170
193
for _ , tc := range tcs {
0 commit comments