Skip to content

Commit 8a4c538

Browse files
committed
Fix tests and ESLint issues after GeoIP database update
- Update test IP addresses to match new GeoIP database - Replace 104.113.255.255 (now US) with 83.13.246.1 (PL - Warsaw) - Adjust expected area value from 20 to 10 - Fix ESLint violations in updatedb.js - Move log utility declaration before first usage - Rename function parameters to avoid shadowing 'args' - Fix indentation issue in processData function - All 94 tests passing - ESLint compliance verified
1 parent 9fb23b5 commit 8a4c538

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

test/advanced.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ describe('Advanced GeoIP2 Tests', () => {
182182

183183
describe('#EUFlag', () => {
184184
it('should have EU flag "1" for EU countries', () => {
185-
const poland = geoIp2.lookup('104.113.255.255');
185+
const poland = geoIp2.lookup('83.13.246.1');
186186
expect(poland.eu).toBe('1');
187187

188188
const netherlands = geoIp2.lookup('2001:1c04:400::1');

test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ describe('GeoIP2', () => {
1616

1717
describe('#testDataIP4', () => {
1818
it('should match data for IPv4 - PL', () => {
19-
const actual = geoIp2.lookup('104.113.255.255');
19+
const actual = geoIp2.lookup('83.13.246.1');
2020
expect(actual.country).toBe('PL');
2121
expect(actual.region).toBe('14');
2222
expect(actual.eu).toBe('1');
2323
expect(actual.timezone).toBe('Europe/Warsaw');
2424
expect(actual.city).toBe('Warsaw');
2525
expect(actual.ll).toBeTruthy();
2626
expect(actual.metro).toBe(0);
27-
expect(actual.area).toBe(20);
27+
expect(actual.area).toBe(10);
2828
});
2929

3030
it('should match data for IPv4 - US', () => {

tools/updatedb.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ const AdmZip = require('adm-zip');
2626
const utils = require('../lib/utils.js');
2727
const { Address6, Address4 } = require('ip-address');
2828

29+
// ============================================================================
30+
// Utility Functions - Logging
31+
// ============================================================================
32+
33+
// Logging utility for consistent and readable output
34+
const log = {
35+
info: (msg, ...logArgs) => console.log('[INFO]', msg, ...logArgs),
36+
success: (msg, ...logArgs) => console.log('[SUCCESS]', msg, ...logArgs),
37+
warn: (msg, ...logArgs) => console.warn('[WARN]', msg, ...logArgs),
38+
error: (msg, ...logArgs) => console.error('[ERROR]', msg, ...logArgs),
39+
progress: (msg) => process.stdout.write(`[INFO] ${msg}... `),
40+
done: () => console.log('Done'),
41+
};
42+
2943
// ============================================================================
3044
// Configuration
3145
// ============================================================================
@@ -82,16 +96,6 @@ const databases = [{
8296
// Utility Functions
8397
// ============================================================================
8498

85-
// Logging utility for consistent and readable output
86-
const log = {
87-
info: (msg, ...args) => console.log('[INFO]', msg, ...args),
88-
success: (msg, ...args) => console.log('[SUCCESS]', msg, ...args),
89-
warn: (msg, ...args) => console.warn('[WARN]', msg, ...args),
90-
error: (msg, ...args) => console.error('[ERROR]', msg, ...args),
91-
progress: (msg) => process.stdout.write(`[INFO] ${msg}... `),
92-
done: () => console.log('Done'),
93-
};
94-
9599
function mkdir(dirName) {
96100
const dir = path.dirname(dirName);
97101
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
@@ -607,7 +611,7 @@ function processData(database, cb) {
607611
processCityDataNames(src[0], dest[0], () => {
608612
processCityData(src[1], dest[1]).then(() => {
609613
process.stdout.write('\n');
610-
log.info('City IPv4 data processed');
614+
log.info('City IPv4 data processed');
611615
return processCityData(src[2], dest[2]);
612616
}).then(() => {
613617
log.info('City IPv6 data processed');

0 commit comments

Comments
 (0)