Skip to content

Commit

Permalink
update-test-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvergara committed Jun 22, 2024
1 parent 66399a3 commit ec3b8f8
Show file tree
Hide file tree
Showing 27 changed files with 540 additions and 55 deletions.
459 changes: 459 additions & 0 deletions test/lib/generated_classes.dart

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions test/test/cleanup.dart

This file was deleted.

2 changes: 1 addition & 1 deletion test/test/datatypes/big_serial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performBigSerialTests(SupabaseClient supabase) async {
BigInt insertBigSerial = BigInt.from(4221312931259329921);
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/bit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../cleanup.dart';
import '../utils.dart';

Future<void> performBitTest(SupabaseClient supabase) async {
String insertBit = "0";
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/bit_varying.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performBitVaryingTest(SupabaseClient supabase) async {
String insertBitVarying = "0";
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performBoxTest(SupabaseClient supabase) async {
// Test values for box
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/bytea.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:supabase/supabase.dart';
import 'package:test/test.dart';
import '../cleanup.dart';
import '../utils.dart';
import 'package:supadart_test/generated_classes.dart'; // Adjust the path as needed

Future<void> performByteaTest(SupabaseClient supabase) async {
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/character.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performCharacterTest(SupabaseClient supabase) async {
// Test values for character
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/character_varying.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performCharacterVaryingTest(SupabaseClient supabase) async {
// Test values for character varying
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/bool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performBooleanTest(SupabaseClient supabase) async {
bool insertBoolean = true;
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performDateTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/float4_real.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performRealTest(SupabaseClient supabase) async {
// real = single precision floating point number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performDoublePrecisionTest(SupabaseClient supabase) async {
// double precision floating point number
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/int2_small_int.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../../cleanup.dart'; // Assuming this contains your cleanup function
import '../../utils.dart'; // Assuming this contains your cleanup function

Future<void> performSmallintTest(SupabaseClient supabase) async {
// int2
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/int4_int.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performIntegerTest(SupabaseClient supabase) async {
// int4 = four-byte signed integer
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/int8_big_int.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performBigIntTest(SupabaseClient supabase) async {
// int8
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performJsonTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/jsonb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performJsonbTest(SupabaseClient supabase) async {
// jsonb
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/numeric.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/test.dart';

import '../../cleanup.dart';
import '../../utils.dart';

// https://dart.dev/guides/language/numbers
// For other cases where precision matters, consider other numeric types. The BigInt type provides arbitrary-precision integers on both native and web. The fixnum package provides strict 64-bit signed numbers, even on the web. Use these types with care, though: they often result in significantly bigger and slower code.
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performTimeTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/timestamp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performTimestampTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/timestamptz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performTimestamptzTest(SupabaseClient supabase) async {
DateTime insertTimestamptz = DateTime(2021, 10, 10, 10, 10, 10);
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/timetz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performTimeTzTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/editor-supported/uuid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

import '../../cleanup.dart';
import '../../utils.dart';

Future<void> performUuidTest(SupabaseClient supabase) async {
// json
Expand Down
2 changes: 1 addition & 1 deletion test/test/datatypes/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import '../cleanup.dart';
import '../utils.dart';

Future<void> performTextTest(SupabaseClient supabase) async {
// Test values for text
Expand Down
43 changes: 22 additions & 21 deletions test/test/supadart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'datatypes/editor-supported/timestamptz.dart';
import 'datatypes/editor-supported/timetz.dart';
import 'datatypes/editor-supported/uuid.dart';
import 'datatypes/text.dart';
import 'utils.dart';

void main() async {
var env = DotEnv(includePlatformEnvironment: true)..load();
Expand All @@ -35,29 +36,29 @@ void main() async {
print('Please provide SUPABASE_URL and SUPABASE_ANON_KEY in .env file');
return;
}

await changeSupabaseFlutterImportToSupabaseImport();
final supabase = SupabaseClient(url, anonKey);
await performSmallintTest(supabase);
await performIntegerTest(supabase);
await performBigIntTest(supabase);
await performRealTest(supabase);
await performDoublePrecisionTest(supabase);
await performNumericTest(supabase);
await performJsonTest(supabase);
await performJsonbTest(supabase);
await performTextTest(supabase);
await performCharacterVaryingTest(supabase);
await performUuidTest(supabase);
await performDateTest(supabase);
await performTimeTest(supabase);
await performTimeTzTest(supabase);
await performTimestampTest(supabase);
await performTimestamptzTest(supabase);
await performBooleanTest(supabase);
// await performSmallintTest(supabase);
// await performIntegerTest(supabase);
// await performBigIntTest(supabase);
// await performRealTest(supabase);
// await performDoublePrecisionTest(supabase);
// await performNumericTest(supabase);
// await performJsonTest(supabase);
// await performJsonbTest(supabase);
// await performTextTest(supabase);
// await performCharacterVaryingTest(supabase);
// await performUuidTest(supabase);
// await performDateTest(supabase);
// await performTimeTest(supabase);
// await performTimeTzTest(supabase);
// await performTimestampTest(supabase);
// await performTimestamptzTest(supabase);
// await performBooleanTest(supabase);

await performCharacterTest(supabase);
await performBigSerialTests(supabase);
await performBitTest(supabase);
// await performCharacterTest(supabase);
// await performBigSerialTests(supabase);
// await performBitTest(supabase);

// todo

Expand Down
36 changes: 36 additions & 0 deletions test/test/utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:supabase/supabase.dart';
import 'package:supadart_test/generated_classes.dart';
import 'dart:io';

Future<void> cleanup(SupabaseClient supabase) async {
try {
await supabase.test_table.delete().eq(Test_table.c_cleanup, "1");
} catch (err) {
print("Error cleaning up");
print(err);
}
}

Future<void> changeSupabaseFlutterImportToSupabaseImport() async {
// Define the path to the file
final filePath = './lib/hello.dart';

final file = File(filePath);
if (!await file.exists()) {
print('File does not exist.');
return;
}

List<String> lines = await file.readAsLines();

if (lines.isNotEmpty) {
lines[0] = "import 'package:supabase/supabase.dart';";
} else {
lines.add("import 'package:supabase/supabase.dart';");
}

// Write the modified content back to the file
await file.writeAsString(lines.join('\n'));

print('File modified successfully.');
}

0 comments on commit ec3b8f8

Please sign in to comment.