mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
enable unit test
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
library;
|
||||
|
||||
export 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||||
|
||||
export 'src/client.dart';
|
||||
|
||||
1
bindings/dart/rust/.gitignore
vendored
1
bindings/dart/rust/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/target
|
||||
/test_build
|
||||
44
bindings/dart/test/_memory_test.dart
Normal file
44
bindings/dart/test/_memory_test.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:turso_dart/src/rust/frb_generated.dart';
|
||||
import 'package:turso_dart/turso_dart.dart';
|
||||
|
||||
void main() async {
|
||||
setUpAll(() async {
|
||||
final lib = await loadExternalLibrary(
|
||||
ExternalLibraryLoaderConfig(
|
||||
stem: "turso_dart",
|
||||
ioDirectory: "rust/test_build/debug/",
|
||||
webPrefix: null,
|
||||
),
|
||||
);
|
||||
await RustLib.init(externalLibrary: lib);
|
||||
});
|
||||
|
||||
test('should be able to perform queries', () async {
|
||||
final client = TursoClient.memory();
|
||||
await client.connect();
|
||||
|
||||
await client.execute(
|
||||
"create table if not exists tasks (id integer primary key, title text, description text, completed integer)",
|
||||
);
|
||||
|
||||
final rowsAffected = await client.execute(
|
||||
"insert into tasks (title, description, completed) values (?, ?, ?)",
|
||||
positional: ["title", "description", 0],
|
||||
);
|
||||
expect(rowsAffected, equals(1));
|
||||
|
||||
final result = await client.query("select * from tasks");
|
||||
expect(
|
||||
result,
|
||||
equals([
|
||||
{
|
||||
"id": 1,
|
||||
"title": "title",
|
||||
"description": "description",
|
||||
"completed": 0,
|
||||
},
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user