Skip to content

Fix temporal ITs to only generate DST-safe time #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions test/v1/temporal-types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ const MIN_TIME_ZONE_OFFSET = -MAX_TIME_ZONE_OFFSET;
const SECONDS_PER_MINUTE = 60;
const MIN_ZONE_ID = 'Etc/GMT+12';
const MAX_ZONE_ID = 'Etc/GMT-14';
const ZONE_IDS = ['Europe/Zaporozhye', 'America/Argentina/Mendoza', 'Etc/GMT-12', 'Asia/Jayapura', 'Pacific/Auckland', 'America/Argentina/Rio_Gallegos',
'America/Tegucigalpa', 'Europe/Skopje', 'Africa/Lome', 'America/Eirunepe', 'Pacific/Port_Moresby', 'America/Merida', 'Asia/Qyzylorda', 'Hongkong',
'America/Paramaribo', 'Pacific/Wallis', 'Antarctica/Mawson', 'America/Metlakatla', 'Indian/Reunion', 'Asia/Chungking', 'Canada/Central', 'Etc/GMT-6',
'UCT', 'America/Belem', 'Europe/Belgrade', 'Singapore', 'Israel', 'Europe/London', 'America/Yellowknife', 'Europe/Uzhgorod', 'Etc/GMT+7',
'America/Indiana/Winamac', 'Asia/Kuala_Lumpur', 'America/Cuiaba', 'Europe/Sofia', 'Asia/Kuching', 'Australia/Lord_Howe', 'America/Porto_Acre',
'America/Indiana/Indianapolis', 'Africa/Windhoek', 'Atlantic/Cape_Verde', 'Asia/Kuwait', 'America/Barbados', 'Egypt', 'GB-Eire', 'Antarctica/South_Pole',
'America/Kentucky/Louisville', 'Asia/Yangon', 'CET', 'Etc/GMT+11', 'Asia/Dubai', 'Europe/Stockholm'];
const ZONE_IDS = ['Europe/Zaporozhye', 'Europe/London', 'UTC', 'Africa/Cairo'];

describe('temporal-types', () => {

Expand Down Expand Up @@ -434,18 +428,22 @@ describe('temporal-types', () => {

function randomDateTimeWithZoneOffset() {
return new neo4j.DateTimeWithZoneOffset(
randomLocalDateTime(),
randomDstSafeLocalDateTime(),
randomZoneOffsetSeconds()
);
}

function randomDateTimeWithZoneId() {
return new neo4j.DateTimeWithZoneId(
randomLocalDateTime(),
randomDstSafeLocalDateTime(),
randomZoneId()
);
}

function randomDstSafeLocalDateTime() {
return new neo4j.LocalDateTime(randomDate(), randomDstSafeLocalTime());
}

function randomLocalDateTime() {
return new neo4j.LocalDateTime(randomDate(), randomLocalTime());
}
Expand Down Expand Up @@ -474,6 +472,15 @@ describe('temporal-types', () => {
);
}

function randomDstSafeLocalTime() {
return new neo4j.LocalTime(
randomInt(4, 23), // do not generate hours in range where DST adjustment happens
randomInt(0, 59),
randomInt(0, 59),
randomInt(0, MAX_NANO_OF_SECOND)
);
}

function randomZoneOffsetSeconds() {
const randomOffsetWithSeconds = neo4j.int(randomInt(MIN_TIME_ZONE_OFFSET, MAX_TIME_ZONE_OFFSET));
return randomOffsetWithSeconds.div(SECONDS_PER_MINUTE).multiply(SECONDS_PER_MINUTE); // truncate seconds
Expand Down