1+ classdef TestUuid < tests .Prep
2+ % TestUuid tests uuid scenarios.
3+ methods (Test )
4+ function testInsertFetch(testCase )
5+ st = dbstack ;
6+ disp([' ---------------' st(1 ).name ' ---------------' ]);
7+ package = ' University' ;
8+
9+ c1 = dj .conn(...
10+ testCase .CONN_INFO .host ,...
11+ testCase .CONN_INFO .user ,...
12+ testCase .CONN_INFO .password ,' ' ,true );
13+
14+ dj .createSchema(package ,[testCase .test_root ' /test_schemas' ], ...
15+ [testCase .PREFIX ' _university' ]);
16+
17+ test_val1 = ' 1d751e2e-1e74-faf8-4ab4-85fde8ef72be' ;
18+ insert(University .Message , struct( ...
19+ ' msg_id' , test_val1 , ...
20+ ' body' , ' Great campus!' ...
21+ ));
22+
23+ test_val2 = ' 12321346-1312-4123-1234-312739283795' ;
24+ insert(University .Message , struct( ...
25+ ' msg_id' , test_val2 , ...
26+ ' body' , ' Where can I find the gym?' ...
27+ ));
28+
29+ q = University .Message ;
30+ res = q .fetch(' msg_id' );
31+ value_check = res(1 ).msg_id;
32+
33+ testCase .verifyEqual(value_check , test_val2 );
34+ end
35+ function testQuery(testCase )
36+ st = dbstack ;
37+ disp([' ---------------' st(1 ).name ' ---------------' ]);
38+ package = ' University' ;
39+
40+ c1 = dj .conn(...
41+ testCase .CONN_INFO .host ,...
42+ testCase .CONN_INFO .user ,...
43+ testCase .CONN_INFO .password ,' ' ,true );
44+
45+ test_val1 = ' 1d751e2e-1e74-faf8-4ab4-85fde8ef72be' ;
46+ test_val2 = ' 12321346-1312-4123-1234-312739283795' ;
47+
48+ q = University .Message & [struct(' msg_id' ,test_val1 ),struct(' msg_id' ,test_val2 )];
49+ res = q .fetch(' msg_id' );
50+ value_check = res(2 ).msg_id;
51+
52+ testCase .verifyEqual(value_check , test_val1 );
53+ end
54+ function testReverseEngineering(testCase )
55+ st = dbstack ;
56+ disp([' ---------------' st(1 ).name ' ---------------' ]);
57+ q = University .Message ;
58+ raw_def = dj .internal .Declare .getDefinition(q );
59+ assembled_def = describe(q );
60+ raw_sql = dj .internal .Declare .declare(q , raw_def );
61+ assembled_sql = dj .internal .Declare .declare(q , assembled_def );
62+ testCase .verifyEqual(raw_sql , assembled_sql );
63+ end
64+ end
65+ end
0 commit comments