Skip to content

Commit

Permalink
refactor(cpp): uSAGE_URL constant string
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Jul 13, 2023
1 parent 8306fd9 commit 9c92ca8
Show file tree
Hide file tree
Showing 10 changed files with 958 additions and 957 deletions.
1,874 changes: 936 additions & 938 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/cpp/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace node_rfc {
extern Napi::Env __env;
extern char const* USAGE_URL;

uint_t Client::_id = 1;
std::mutex Client::invocationMutex;
Expand Down Expand Up @@ -602,7 +603,7 @@ ErrorPair Client::connectionCheck(RFC_ERROR_INFO* errorInfo) {
return ErrorPair(errorInfoOpen, updateError);
}

DEBUG("// assign new handle to managed client");
DEBUG("new handle assigned to managed client");
this->connectionHandle = new_handle;
} else {
// assign new handle to direct client
Expand Down
1 change: 1 addition & 0 deletions src/cpp/Pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Throughput.h"

namespace node_rfc {
extern char const* USAGE_URL;
uint_t Pool::_id = 1;
std::mutex leaseMutex;

Expand Down
1 change: 1 addition & 0 deletions src/cpp/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace node_rfc {
extern Napi::Env __env;
extern char const* USAGE_URL;

uint_t Server::_id = 1;

Expand Down
1 change: 1 addition & 0 deletions src/cpp/addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace node_rfc {
Napi::Env __env = NULL;
std::mutex invocationMutex;
char const* USAGE_URL = ": https://github.com/SAP/node-rfc#usage";

Napi::Value BindingVersions(Napi::Env env) {
uint_t major, minor, patchLevel;
Expand Down
2 changes: 0 additions & 2 deletions src/cpp/noderfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <sapnwrfc.h>
#include <iostream>

#define USAGE_URL ": https://github.com/SAP/node-rfc#usage"

// Unsigned and pointer types
#define uint_t uint32_t
#define pointer_t uintptr_t
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/nwrfcsdk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace node_rfc {
extern Napi::Env __env;
extern char const* USAGE_URL;

////////////////////////////////////////////////////////////////////////////////
// Set Parameters (to SDK)
Expand Down Expand Up @@ -1082,7 +1083,7 @@ void checkClientOptions(Napi::Object clientOptionsObject,
ERRMSG_LENGTH - 1,
"Client option not allowed: \"%s\"; see %s",
key.c_str(),
USAGE_URL);
node_rfc::USAGE_URL);
Napi::TypeError::New(node_rfc::__env, errmsg)
.ThrowAsJavaScriptException();
}
Expand Down
14 changes: 7 additions & 7 deletions test/addon.methods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
//
// SPDX-License-Identifier: Apache-2.0

import { binding } from "./utils/setup";
import { addon } from "./utils/setup";
import { LANGUAGES } from "./utils/config";

describe("Addon methods", () => {
test("Language Conversions", function () {
expect.assertions(2 * Object.keys(LANGUAGES).length);
for (const [lang, L] of Object.entries(LANGUAGES)) {
const sapLang = binding.languageIsoToSap(lang);
const sapLang = addon.languageIsoToSap(lang);
expect(sapLang).toEqual(L.lang_sap);
const isoLang = binding.languageSapToIso(sapLang);
const isoLang = addon.languageSapToIso(sapLang);
expect(isoLang).toEqual(lang);
}
});

test("Language Conversions Errors", function () {
test.only("Language Conversions Errors", function () {
expect.assertions(2);
const errIso = "ŠĐ";
const errSap = "Š";
try {
binding.languageIsoToSap(errIso);
addon.languageIsoToSap(errIso);
} catch (ex) {
expect((ex as Error).message).toEqual(
`Language ISO code not found: ${errIso}`
);
}
try {
binding.languageSapToIso(errSap);
addon.languageSapToIso(errSap);
} catch (ex) {
expect((ex as Error).message).toEqual(
`Language SAP code not found: ${errSap}`
Expand All @@ -39,7 +39,7 @@ describe("Addon methods", () => {
test("Reload INI file", function () {
expect.assertions(1);
try {
binding.reloadIniFile();
addon.reloadIniFile();
expect(1).toEqual(1);
} catch {
expect(1).toEqual(0);
Expand Down
8 changes: 4 additions & 4 deletions test/client/direct.callback.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

import {
binding,
addon,
dependencies,
direct_client,
refEnvironment,
Expand Down Expand Up @@ -31,10 +31,10 @@ describe("Client: direct callback", () => {
done();
});

test("environment @ binding and Client", function () {
test("environment of addon and Client", function () {
expect.assertions(3);
expect(binding.environment).toMatchObject(refEnvironment);
expect(binding.Client.environment).toMatchObject(refEnvironment);
expect(addon.environment).toMatchObject(refEnvironment);
expect(addon.Client.environment).toMatchObject(refEnvironment);
expect(client.environment).toMatchObject(refEnvironment);
});

Expand Down
8 changes: 4 additions & 4 deletions test/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import os from "os";
import { version } from "../../package.json";
export { version, dependencies } from "../../package.json";
import { Client } from "../../lib";
import * as binding from "../../lib";
export * as binding from "../../lib";
import * as addon from "../../lib";
export * as addon from "../../lib";

export {
Client,
Expand Down Expand Up @@ -78,5 +78,5 @@ export const poolConfiguration = {
connectionParameters: abapSystem(),
};

binding.setIniFileDirectory(sapnwrfcIniPath);
// binding.loadCryptoLibrary(_CryptoLibPath[process.platform]);
addon.setIniFileDirectory(sapnwrfcIniPath);
// addon.loadCryptoLibrary(_CryptoLibPath[process.platform]);

0 comments on commit 9c92ca8

Please sign in to comment.