Skip to content

Commit bf8ed3a

Browse files
committed
Add more test case for datetime objects
1 parent dd3b9ce commit bf8ed3a

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

test/dataTypeDate.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,49 @@ describe('32. dataTypeDate.js', function() {
143143
}));
144144
});
145145
}); // end of 32.3 suite
146+
147+
describe('32.4 Select invalid dates', function() {
148+
149+
it('32.4.1 Negative - Invalid Year 0', async function() {
150+
const invalidYear = 0;
151+
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
152+
153+
await assert.rejects(
154+
async () => {
155+
await connection.execute(sql);
156+
},
157+
/* ORA-01841: (full) year must be between -4713 and +9999, and
158+
not be 0 */
159+
/ORA-01841:/
160+
);
161+
});
162+
163+
it('32.4.2 Negative - Invalid Year -4713', async function() {
164+
const invalidYear = -4713;
165+
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
166+
167+
await assert.rejects(
168+
async () => {
169+
await connection.execute(sql);
170+
},
171+
/* ORA-01841: (full) year must be between -4713 and +9999, and
172+
not be 0 */
173+
/ORA-01841:/
174+
);
175+
});
176+
177+
it('32.4.3 Negative - Invalid Year 10000', async function() {
178+
const invalidYear = 10000;
179+
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
180+
181+
await assert.rejects(
182+
async () => {
183+
await connection.execute(sql);
184+
},
185+
/* ORA-01841: (full) year must be between -4713 and +9999, and
186+
and not be 0 */
187+
/ORA-01841:/
188+
);
189+
});
190+
}); // end of 32.4 suite
146191
});

test/list.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,10 @@ Overview of node-oracledb functional tests
539539
32.3 insert SQL Date data
540540
32.3.1 SELECT query - original data
541541
32.3.2 SELECT query - formatted data for comparison
542-
33.3.3 returns scalar types from PL/SQL block
542+
32.4 Select invalid dates
543+
32.4.1 Negative - Invalid Year 0
544+
32.4.2 Negative - Invalid Year -4713
545+
32.4.3 Negative - Invalid Year 10000
543546

544547
33. dataTypeTimestamp1.js
545548
33.1 Testing JavaScript Date with database TIMESTAMP
@@ -553,6 +556,7 @@ Overview of node-oracledb functional tests
553556
33.3 testing TIMESTAMP without TIME ZONE
554557
32.3.1 SELECT query - original data
555558
33.3.2 SELECT query - formatted data for comparison
559+
33.3.3 returns scalar types from PL/SQL block
556560

557561
34. dataTypeTimestamp2.js
558562
34.1 Testing JavaScript Date with database TIMESTAMP(p)

0 commit comments

Comments
 (0)