Skip to content

Commit

Permalink
more troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Mar 11, 2024
1 parent 87253b8 commit a219c43
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions library/fdb/tests/fdb_tests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ procedure TFDBTests.test(manager: TFDBManager);
i64: Int64;
md: TFDBMetaData;
fn : string;
s : String;
begin
s := '1';
Writeln('t1');
d := TFslDateTime.makeLocal(dtpSec);
fn := TestSettings.serverTestFile(['library', 'fdb', 'tests', 'fdb_tests.pas']);
b := FileToBytes(fn);
Expand All @@ -122,7 +121,7 @@ procedure TFDBTests.test(manager: TFDBManager);
//finally
// md.free;
//end;
s := '2';
Writeln('t2');

conn.ExecSQL('CREATE TABLE TestTable ( ' + #13#10 + ' TestKey ' + DBKeyType(conn.owner.platform) + ' ' + ColCanBeNull(conn.owner.platform, false) + ', ' +
#13#10 + ' Name nchar(255) ' + ColCanBeNull(conn.owner.platform, false) + ', ' + #13#10 + ' Number int ' + ColCanBeNull(conn.owner.platform, true) + ', '
Expand All @@ -131,7 +130,7 @@ procedure TFDBTests.test(manager: TFDBManager);
DBBlobType(conn.owner.platform) + ' ' + ColCanBeNull(conn.owner.platform, true) + ', ' + #13#10 + PrimaryKeyType(conn.owner.platform, 'PK_TestTable',
'TestKey') + ') ' + CreateTableInfo(conn.owner.platform));
conn.ExecSQL('Create Unique INDEX SK_TestTable_Index ON TestTable (Name, Number)');
s := '3';
Writeln('t3');

try
md := conn.FetchMetaData;
Expand All @@ -140,12 +139,12 @@ procedure TFDBTests.test(manager: TFDBManager);
finally
md.free;
end;
s := '4';
Writeln('t4');
assertTrue(conn.CountSQL('Select count(*) from TestTable') = 0, 'dbt.0');

conn.ExecSQL('Insert into TestTable (TestKey, Name, BigString, Number, BigNumber, FloatNumber, Instant) values (1, ''a name'', '''', 2, ' + IntToStr(i64) + ', 3.2, ' +
DBGetDate(manager.platform) + ')');
s := '5';
Writeln('t5');
conn.sql := 'Insert into TestTable (TestKey, Name, BigString, Number, BigNumber, FloatNumber, Instant, Content) values (:k, :n, :bs, :i, :bi, :d, :ts, :c)';
conn.Prepare;
conn.BindKey('k', 2);
Expand All @@ -157,13 +156,13 @@ procedure TFDBTests.test(manager: TFDBManager);
conn.BindDateTimeEx('ts', d);
conn.BindBlob('c', b);
conn.Execute;
s := '6';
Writeln('t6');
conn.Terminate;
s := '7';
Writeln('t7');

assertTrue(conn.CountSQL('Select count(*) from TestTable where TestKey = 1') = 1, 'dbt.1');
assertTrue(conn.CountSQL('Select count(*) from TestTable where TestKey = 0') = 0, 'dbt.2');
s := '8';
Writeln('t8');

dn := TFslDateTime.makeLocal;

Expand Down Expand Up @@ -193,7 +192,7 @@ procedure TFDBTests.test(manager: TFDBManager);
assertTrue(conn.ColDateTimeExByName['Instant'].equal(d, dtpSec), 'dbt.19');
assertTrue(BlobIsSame(conn.ColBlobByName['Content'], b), 'dbt.20');
conn.Terminate;
s := '9';
Writeln('t9');

sleep(1000);

Expand All @@ -210,7 +209,7 @@ procedure TFDBTests.test(manager: TFDBManager);
conn.BindNull('c');
conn.Execute;
conn.Terminate;
s := '10';
Writeln('t10');

conn.sql := 'Select * from TestTable';
conn.Prepare;
Expand All @@ -224,7 +223,7 @@ procedure TFDBTests.test(manager: TFDBManager);
assertTrue(conn.ColDateTimeExByName['Instant'].after(od, false), 'dbt.26');
assertTrue(length(conn.ColBlobByName['Content']) = 0, 'dbt.27');
assertTrue(conn.ColNullByName['Content'], 'dbt.28');
s := '11';
Writeln('t11');

conn.FetchNext;
assertTrue(conn.ColIntegerByName['TestKey'] = 2, 'dbt.29');
Expand All @@ -236,43 +235,42 @@ procedure TFDBTests.test(manager: TFDBManager);
assertTrue(length(conn.ColBlobByName['Content']) = 0, 'dbt.35');
assertTrue(conn.ColNullByName['Content'], 'dbt.36');
conn.Terminate;
s := '12';
Writeln('t12');

conn.ExecSQL('Delete from TestTable where TestKey = 1');
conn.sql := 'Delete from TestTable where TestKey = :k';
conn.Prepare;
conn.BindKey('k', 2);
conn.Execute;
conn.Terminate;
s := '13';
Writeln('t13');

assertTrue(conn.CountSQL('Select count(*) from TestTable') = 0, 'dbt.37');

finally
conn.terminate;
s := '14';
Writeln('t14');
conn.DropTable('TestTable');
s := '15';
Writeln('t15');
end;
md := conn.FetchMetaData;
try
assertFalse(md.HasTable('TestTable'), 'dbt.38')
finally
md.free;
end;
s := '16';
Writeln('t16');

raise EFslException.create('test1');
conn.Release;
raise EFslException.create('test1');
Writeln('t17');
except
on e: Exception do
begin
raise EFslException.create('test2: '+e.message+' ('+s+')');
Writeln('t18');
conn.Error(e);
raise EFslException.create('test3: '+e.message+' ('+s+')');
Writeln('t19');
assertTrue(false, e.message);
raise EFslException.create('test4: '+e.message+' ('+s+')');
Writeln('t20');
end;
end;
end;
Expand Down

0 comments on commit a219c43

Please sign in to comment.