Skip to content

Commit bdb3d32

Browse files
committed
Fix tests
1 parent 4030614 commit bdb3d32

File tree

28 files changed

+58
-72
lines changed

28 files changed

+58
-72
lines changed

templates/android/library/src/main/java/io/package/Query.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class Query(
268268
* @param end The end date value.
269269
* @returns The query string.
270270
*/
271-
fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson()
271+
fun createdBetween(start: String, end: String) = between("\$createdAt", start, end)
272272

273273
/**
274274
* Filter resources where document was updated before date.
@@ -293,7 +293,7 @@ class Query(
293293
* @param end The end date value.
294294
* @returns The query string.
295295
*/
296-
fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson()
296+
fun updatedBetween(start: String, end: String) = between("\$updatedAt", start, end)
297297

298298
/**
299299
* Combine multiple queries using logical OR operator.

templates/dart/lib/query.dart.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Query {
115115

116116
/// Filter resources where document was created between [start] and [end] (inclusive).
117117
static String createdBetween(String start, String end) =>
118-
Query._('createdBetween', null, [start, end]).toString();
118+
between('\$createdAt', start, end);
119119

120120
/// Filter resources where document was updated before [value].
121121
static String updatedBefore(String value) =>
@@ -127,7 +127,7 @@ class Query {
127127

128128
/// Filter resources where document was updated between [start] and [end] (inclusive).
129129
static String updatedBetween(String start, String end) =>
130-
Query._('updatedBetween', null, [start, end]).toString();
130+
between('\$updatedAt', start, end);
131131

132132
static String or(List<String> queries) => Query._(
133133
'or',

templates/dart/test/query_test.dart.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ void main() {
292292

293293
test('returns createdBetween', () {
294294
final query = jsonDecode(Query.createdBetween('2023-01-01', '2023-12-31'));
295-
expect(query['attribute'], null);
295+
expect(query['attribute'], '\$createdAt');
296296
expect(query['values'], ['2023-01-01', '2023-12-31']);
297-
expect(query['method'], 'createdBetween');
297+
expect(query['method'], 'between');
298298
});
299299

300300
test('returns updatedBefore', () {
@@ -313,9 +313,9 @@ void main() {
313313

314314
test('returns updatedBetween', () {
315315
final query = jsonDecode(Query.updatedBetween('2023-01-01', '2023-12-31'));
316-
expect(query['attribute'], null);
316+
expect(query['attribute'], '\$updatedAt');
317317
expect(query['values'], ['2023-01-01', '2023-12-31']);
318-
expect(query['method'], 'updatedBetween');
318+
expect(query['method'], 'between');
319319
});
320320
}
321321

templates/deno/src/query.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class Query {
184184
* @returns {string}
185185
*/
186186
static createdBetween = (start: string, end: string): string =>
187-
new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();
187+
Query.between("$createdAt", start, end);
188188

189189
/**
190190
* Filter resources where document was updated before date.
@@ -212,7 +212,7 @@ export class Query {
212212
* @returns {string}
213213
*/
214214
static updatedBetween = (start: string, end: string): string =>
215-
new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();
215+
Query.between("$updatedAt", start, end);
216216

217217
static or = (queries: string[]) =>
218218
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();

templates/deno/test/query.test.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('Query', () => {
225225

226226
test('createdBetween', () => assertEquals(
227227
Query.createdBetween('2023-01-01', '2023-12-31').toString(),
228-
`{"method":"createdBetween","values":["2023-01-01","2023-12-31"]}`,
228+
`{"method":"between","attribute":"$createdAt","values":["2023-01-01","2023-12-31"]}`,
229229
));
230230

231231
test('updatedBefore', () => assertEquals(
@@ -240,6 +240,6 @@ describe('Query', () => {
240240

241241
test('updatedBetween', () => assertEquals(
242242
Query.updatedBetween('2023-01-01', '2023-12-31').toString(),
243-
`{"method":"updatedBetween","values":["2023-01-01","2023-12-31"]}`,
243+
`{"method":"between","attribute":"$updatedAt","values":["2023-01-01","2023-12-31"]}`,
244244
));
245245
})

templates/dotnet/Package/Query.cs.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ namespace {{ spec.title | caseUcfirst }}
191191
}
192192

193193
public static string CreatedBetween(string start, string end) {
194-
return new Query("createdBetween", null, new List<string> { start, end }).ToString();
194+
return Between("$createdAt", start, end);
195195
}
196196

197197
public static string UpdatedBefore(string value) {
@@ -203,7 +203,7 @@ namespace {{ spec.title | caseUcfirst }}
203203
}
204204

205205
public static string UpdatedBetween(string start, string end) {
206-
return new Query("updatedBetween", null, new List<string> { start, end }).ToString();
206+
return Between("$updatedAt", start, end);
207207
}
208208

209209
public static string Or(List<string> queries) {

templates/go/query.go.twig

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ func CreatedAfter(value interface{}) string {
210210
}
211211

212212
func CreatedBetween(start, end interface{}) string {
213-
values := []interface{}{start, end}
214-
return parseQuery(queryOptions{
215-
Method: "createdBetween",
216-
Values: &values,
217-
})
213+
return Between("$createdAt", start, end)
218214
}
219215

220216
func UpdatedBefore(value interface{}) string {
@@ -226,11 +222,7 @@ func UpdatedAfter(value interface{}) string {
226222
}
227223

228224
func UpdatedBetween(start, end interface{}) string {
229-
values := []interface{}{start, end}
230-
return parseQuery(queryOptions{
231-
Method: "updatedBetween",
232-
Values: &values,
233-
})
225+
return Between("$updatedAt", start, end)
234226
}
235227

236228
func Select(attributes interface{}) string {

templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ class Query(
6767

6868
fun createdAfter(value: String) = greaterThan("\$createdAt", value)
6969

70-
fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson()
70+
fun createdBetween(start: String, end: String) = between("\$createdAt", start, end)
7171

7272
fun updatedBefore(value: String) = lessThan("\$updatedAt", value)
7373

7474
fun updatedAfter(value: String) = greaterThan("\$updatedAt", value)
7575

76-
fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson()
76+
fun updatedBetween(start: String, end: String) = between("\$updatedAt", start, end)
7777

7878
fun or(queries: List<String>) = Query("or", null, queries.map { it.fromJson<Query>() }).toJson()
7979

templates/php/src/Query.php.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class Query implements \JsonSerializable
369369
*/
370370
public static function createdBetween(string $start, string $end): string
371371
{
372-
return (new Query('createdBetween', null, [$start, $end]))->__toString();
372+
return self::between('$createdAt', $start, $end);
373373
}
374374
375375
/**
@@ -403,7 +403,7 @@ class Query implements \JsonSerializable
403403
*/
404404
public static function updatedBetween(string $start, string $end): string
405405
{
406-
return (new Query('updatedBetween', null, [$start, $end]))->__toString();
406+
return self::between('$updatedAt', $start, $end);
407407
}
408408
409409
/**

templates/php/tests/QueryTest.php.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ final class QueryTest extends TestCase {
188188
}
189189
190190
public function testCreatedBetween(): void {
191-
$this->assertSame('{"method":"createdBetween","values":["2023-01-01","2023-12-31"]}', Query::createdBetween('2023-01-01', '2023-12-31'));
191+
$this->assertSame('between("$createdAt", ["2023-01-01","2023-12-31"])', Query::createdBetween('2023-01-01', '2023-12-31'));
192192
}
193193
194194
public function testUpdatedBefore(): void {
@@ -200,6 +200,6 @@ final class QueryTest extends TestCase {
200200
}
201201
202202
public function testUpdatedBetween(): void {
203-
$this->assertSame('{"method":"updatedBetween","values":["2023-01-01","2023-12-31"]}', Query::updatedBetween('2023-01-01', '2023-12-31'));
203+
$this->assertSame('between("$updatedAt", ["2023-01-01","2023-12-31"])', Query::updatedBetween('2023-01-01', '2023-12-31'));
204204
}
205205
}

0 commit comments

Comments
 (0)