forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate block of unit tests to
node:test
- Loading branch information
1 parent
2f7a5f0
commit 311593a
Showing
3 changed files
with
455 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,45 @@ | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
const tap = require('tap') | ||
const util = require('../../lib/db/utils') | ||
|
||
tap.test('DB Utilities:', function (t) { | ||
const useParser = util.extractDatabaseChangeFromUse | ||
|
||
t.test('should match single statement use expressions', function (t) { | ||
t.equal(useParser('use test_db;'), 'test_db') | ||
t.equal(useParser('USE INIT'), 'INIT') | ||
t.end() | ||
}) | ||
|
||
t.test('should not be sensitive to ; omission', function (t) { | ||
t.equal(useParser('use test_db'), 'test_db') | ||
t.end() | ||
}) | ||
|
||
t.test('should not be sensitive to extra ;', function (t) { | ||
t.equal(useParser('use test_db;;;;;;'), 'test_db') | ||
t.end() | ||
}) | ||
|
||
t.test('should not be sensitive to extra white space', function (t) { | ||
t.equal(useParser(' use test_db;'), 'test_db') | ||
t.equal(useParser('use test_db;'), 'test_db') | ||
t.equal(useParser(' use test_db;'), 'test_db') | ||
t.equal(useParser('use test_db ;'), 'test_db') | ||
t.equal(useParser('use test_db; '), 'test_db') | ||
t.end() | ||
}) | ||
|
||
t.test('should match backtick expressions', function (t) { | ||
t.equal(useParser('use `test_db`;'), '`test_db`') | ||
t.equal(useParser('use `☃☃☃☃☃☃`;'), '`☃☃☃☃☃☃`') | ||
t.end() | ||
}) | ||
|
||
t.test('should not match malformed use expressions', function (t) { | ||
t.equal(useParser('use cxvozicjvzocixjv`oasidfjaosdfij`;'), null) | ||
t.equal(useParser('use `oasidfjaosdfij`123;'), null) | ||
t.equal(useParser('use `oasidfjaosdfij` 123;'), null) | ||
t.equal(useParser('use \u0001;'), null) | ||
t.equal(useParser('use oasidfjaosdfij 123;'), null) | ||
t.end() | ||
}) | ||
t.end() | ||
|
||
const test = require('node:test') | ||
const assert = require('node:assert') | ||
|
||
const useParser = require('../../lib/db/utils').extractDatabaseChangeFromUse | ||
|
||
test('should match single statement use expressions', () => { | ||
assert.equal(useParser('use test_db;'), 'test_db') | ||
assert.equal(useParser('USE INIT'), 'INIT') | ||
}) | ||
|
||
test('should not be sensitive to ; omission', () => { | ||
assert.equal(useParser('use test_db'), 'test_db') | ||
}) | ||
|
||
test('should not be sensitive to extra ;', () => { | ||
assert.equal(useParser('use test_db;;;;;;'), 'test_db') | ||
}) | ||
|
||
test('should not be sensitive to extra white space', () => { | ||
assert.equal(useParser(' use test_db;'), 'test_db') | ||
assert.equal(useParser('use test_db;'), 'test_db') | ||
assert.equal(useParser(' use test_db;'), 'test_db') | ||
assert.equal(useParser('use test_db ;'), 'test_db') | ||
assert.equal(useParser('use test_db; '), 'test_db') | ||
}) | ||
|
||
test('should match backtick expressions', () => { | ||
assert.equal(useParser('use `test_db`;'), '`test_db`') | ||
assert.equal(useParser('use `☃☃☃☃☃☃`;'), '`☃☃☃☃☃☃`') | ||
}) | ||
|
||
test('should not match malformed use expressions', () => { | ||
assert.equal(useParser('use cxvozicjvzocixjv`oasidfjaosdfij`;'), null) | ||
assert.equal(useParser('use `oasidfjaosdfij`123;'), null) | ||
assert.equal(useParser('use `oasidfjaosdfij` 123;'), null) | ||
assert.equal(useParser('use \u0001;'), null) | ||
assert.equal(useParser('use oasidfjaosdfij 123;'), null) | ||
}) |
Oops, something went wrong.