How to use getEnvironment method in Best

Best JavaScript code snippet using best

service.js

Source:service.js Github

copy

Full Screen

...5////////////////////////////////////////////////////////////////////6export const getProjectList = (name, current, size) => {7 return request(`/projects?name=${name}&current=${current}&size=${size}`, {8 labels: {9 route: getEnvironment()10 }11 }, { method: "POST" });12};13export const createProject = (body) => {14 return request("/createProject", {15 ...body,16 labels: {17 route: getEnvironment()18 }19 });20};21export const deleteProject = (id) => {22 return request("/projects/" + id, {23 labels: {24 route: getEnvironment()25 }26 }, {27 method: "DELETE",28 });29};30export const getProjectById = (id) => {31 return request("/projects/" + id + '?labels=' + getEnvironment(), null, {32 method: "GET",33 });34};35export const updateProject = (body) => {36 return request("/updateProject", {37 ...body,38 labels: {39 route: getEnvironment()40 }41 }, {42 method: "PUT",43 });44};45export const getDataSourceList = (params) => {46 return request("/datasources/query", {47 ...params,48 labels: {49 route: getEnvironment()50 }51 }, { method: "POST" });52};53// 数据源管理 获取数据源54export const getDataSourceTypes = () => {55 return request(56 `/datasources/type?labels=${getEnvironment()}&t=_${new Date().getTime()}`,57 {},58 { method: "GET" }59 );60};61// 数据源管理 获取动态参数62export const getKeyDefine = (dataSourceTypeId) => {63 return request(64 `/datasources/types/${dataSourceTypeId}/keydefines?labels=${getEnvironment()}&t=_${new Date().getTime()}`,65 {},66 { method: "GET" }67 );68};69// 查询数据源70export const getDataSource = (body) => {71 return request("/datasources/query", {72 ...body,73 labels: {74 route: getEnvironment()75 }76 }, { method: "POST" });77};78export const getDBs = (type, id) => {79 return request(`/datasources/${type}/${id}/dbs?labels=${getEnvironment()}`, {}, { method: "GET" });80};81export const getTables = (type, id, dbName) => {82 return request(83 `/datasources/${type}/${id}/dbs/${dbName}/tables?labels=${getEnvironment()}`,84 {},85 { method: "GET" }86 );87};88/*export const getFields = (type, id, dbName, tableName) => {89 return request(90 `/datasources/${type}/${id}/dbs/${dbName}/tables/${tableName}/fields`,91 {},92 { method: "GET" }93 );94};*/95export const getFields = (params) => {96 return request(97 `/datasources/fieldsmapping`,98 {99 ...params,100 labels: {101 route: getEnvironment()102 }103 },104 { method: "POST" }105 );106};107export const createDataSource = (params) => {108 return request("/datasources", {109 ...params,110 labels: {111 route: getEnvironment()112 }113 }, { method: "POST" });114};115export const updateDataSource = (id, params) => {116 return request("/datasources/" + id, {117 ...params,118 labels: {119 route: getEnvironment()120 }121 }, { method: "PUT" });122};123export const deleteDataSource = (id) => {124 return request(`/datasources/${id}`, {125 labels: {126 route: getEnvironment()127 }128 }, { method: "DELETE" });129};130export const getDataSourceVersionList = (id) => {131 return request(`/datasources/${id}/versions?labels=${getEnvironment()}`, {}, { method: "GET" });132};133export const testDataSourceConnect = (type, id) => {134 return request(`/datasources/${type}/${id}/connect?_=${Math.random()}`, {135 labels: {136 route: getEnvironment()137 }138 }, { method: "PUT" });139};140export const testDataSourceNotSavedConnect = (params) => {141 return request(`/datasources/op/connect?_=${Math.random()}`, {142 ...params,143 labels: {144 route: getEnvironment()145 }146 }, { method: "POST" });147};148export const getDataSourceById = (id, versionId) => {149 return request(`/datasources/${id}?labels=${getEnvironment()}`, {versionId}, { method: "GET" });150};151export const getJobInfo = (id) => {152 return request(`/job/${id}?labels=${getEnvironment()}`, null, {153 method: "GET",154 });155};156//获取任务列表157export const getJobList = (query) => {158 return request(`/job?labels=${getEnvironment()}&${query}`, null, {159 method: "GET",160 });161};162//获取执行引擎列表163export const getEngineType = () => {164 return request(`/job/engineType?labels=${getEnvironment()}`, null, {165 method: "GET",166 });167};168//新建任务169export const createJob = (params) => {170 return request(171 `/job`,172 {173 ...params,174 labels: {175 route: getEnvironment()176 }177 },178 {179 method: "POST",180 }181 );182};183//复制任务184export const copyJob = (id, params) => {185 return request(186 `/job/${id}/copy`,187 {188 ...params,189 labels: {190 route: getEnvironment()191 }192 },193 {194 method: "POST",195 }196 );197};198//编辑任务199export const modifyJob = (id, params) => {200 return request(201 `/job/${id}`,202 {203 ...params,204 labels: {205 route: getEnvironment()206 }207 },208 {209 method: "PUT",210 }211 );212};213//删除任务214export const deleteJob = (id) => {215 return request(`/job/${id}`, {216 labels: {217 route: getEnvironment()218 }219 }, {220 method: "DELETE",221 });222};223//导入任务224export const importJob = (id, params) => {225 return request(226 `/job/import`,227 {228 ...params,229 labels: {230 route: getEnvironment()231 }232 },233 {234 method: "POST",235 }236 );237};238//执行任务239export const executeTask = (id) => {240 return request(`/job/${id}/action/execute`, {241 labels: {242 route: getEnvironment()243 }244 }, {245 method: "POST",246 });247};248export const getJobs = (id, jobType, name, current, size) => {249 return request(`/job?labels=${getEnvironment()}&projectId=${id}&jobType=${jobType}&name=${name}&current=${current}&size=${size}`, null, {250 method: "GET",251 });252};253export const saveProject = (id, body) => {254 return request(`/job/${id}/content`, {255 ...body,256 labels: {257 route: getEnvironment()258 }259 }, {260 method: "PUT",261 });262};263// 保存/更新任务配置264export const updateTaskConfiguration = (id, body) => {265 return request(`/job/${id}/config`, {266 ...body,267 labels: {268 route: getEnvironment()269 }270 }, {271 method: "PUT",272 });273};274export const expireDataSource = (id) => {275 return request(`/datasources/${id}/expire`, {276 labels: {277 route: getEnvironment()278 }279 }, { method: "PUT" });280};281export const publishDataSource = (id, versionId) => {282 return request(283 `/datasources/${id}/${versionId}/publish`,284 {285 labels: {286 route: getEnvironment()287 }288 },289 { method: "PUT" }290 );291};292export const getSourceParams = (engineType, type, ds) => {293 return request(294 `/datasources/${engineType}/${type}/params/ui?labels=${getEnvironment()}&dir=${ds}`,295 {},296 { method: "GET" }297 );298};299export const getSettingsParams = (engineType) => {300 return request(301 `/jobs/engine/${engineType}/settings/ui?labels=${getEnvironment()}`,302 {},303 { method: "GET" }304 );305};306// job执行307/*export const executeJob = (id) => {308 return request(`/job/${id}/action/execute`, {}, {309 method: "POST",310 });311};*/312// 同步历史313export const getSyncHistory = (body) => {314 return request("/tasks?labels=" + getEnvironment(), body, {315 method: "GET",316 });317};318// 新版同步历史-获取job列表319export const getSyncHistoryJobList = (body) => {320 return request("/job/listJobs?labels=" + getEnvironment(), body, {321 method: "GET",322 });323};324// 删除同步历史325export const delSyncHistory = (jobExecutionId) => {326 return request(`/job/${jobExecutionId}/deleteJob`, {327 labels: {328 route: getEnvironment()329 }330 }, {331 method: "POST",332 });333};334// 读取Task限速配置335export const getSpeedLimit = (params) => {336 return request(337 `/job/${params.jobId}/speedlimit/${params.taskName}/params/ui?labels=${getEnvironment()}`,338 {},339 {340 method: "GET",341 }342 );343};344// 保存Task限速配置345export const saveSpeedLimit = (params, body) => {346 return request(`/job/${params.jobId}/speedlimit/${params.taskName}`, {347 ...body,348 labels: {349 route: getEnvironment()350 }351 }, {352 method: "PUT",353 });354};355// 获取运行日志356export const getLogs = (params) => {357 return request(358 `/execution/tasks/${params.taskID}/logs?labels=${getEnvironment()}`,359 {360 fromLine: params.fromLine || 1,361 pageSize: params.pageSize || 10362 },363 {364 method: "GET",365 }366 );367}368// 首页相关369// 任务状态370export const getTaskState = () => {371 return request("/metrics/taskstate?labels=" + getEnvironment(), {}, { method: "GET" });372};373// 任务进度374export const getTaskProcess = () => {375 return request("/metrics/taskprocess?labels=" + getEnvironment(), {}, { method: "GET" });376};377// 流量监控378export const getDataSourceFlow = () => {379 return request("/metrics/datasourceflow?labels=" + getEnvironment(), {}, { method: "GET" });380};381// 资源使用382export const getEngineriesSource = () => {383 return request("/metrics/engineresource?labels=" + getEnvironment(), {}, { method: "GET" });384};385export const getEngineriesSourceCpu = () => {386 return request("/metrics/engineresourcecpu?labels=" + getEnvironment(), {}, { method: "GET" });387};388export const getEngineriesSourceMem = () => {389 return request("/metrics/engineresourcemem?labels=" + getEnvironment(), {}, { method: "GET" });390};391/* 作业执行模块接口 */392export const executeJob = (id) => {393 return request(`/job/${id}/execute`,{394 labels: {395 route: getEnvironment()396 }397 }, {398 method: "POST",399 })400}401export const getJobStatus = (id) => {402 return request(`/job/execution/${id}/status?labels=${getEnvironment()}`, {}, {403 method: "GET",404 })405}406export const getJobTasks = (id) => {407 return request(`/job/execution/${id}/taskList?labels=${getEnvironment()}`, null, {408 method: "GET",409 })410}411export const getProgress = (id) => {412 return request(`/job/execution/${id}/progress?labels=${getEnvironment()}&_=${Math.random()}`, null, {413 method: "GET",414 })415}416export const getMetrics = (taskId, jobExecutionId) => {417 return request(`/task/execution/${taskId}/metrics`, {418 jobExecutionId,419 labels: {420 route: getEnvironment()421 }422 }, {423 method: "POST",424 })425}426export const killJob = (id) => {427 return request(`/job/execution/${id}/kill`, {428 labels: {429 route: getEnvironment()430 }431 }, {432 method: "POST",433 })434}435// 获取job运行日志436export const getJobExecLog = (params) => {437 return request(438 `/job/execution/${params.id}/log?labels=${getEnvironment()}&_=${Math.random()}`,439 {440 fromLine: params.fromLine || 0,441 pageSize: params.pageSize || 50,442 onlyKeywords: params.onlyKeywords,443 ignoreKeywords: params.ignoreKeywords,444 lastRows: params.lastRows445 },446 {447 method: "GET",448 }449 );450}451// 获取task运行日志452export const getTaskExecLog = (params) => {453 return request(454 `/task/execution/${params.taskId}/log?labels=${getEnvironment()}&_=${Math.random()}`,455 {456 fromLine: params.fromLine || 0,457 pageSize: params.pageSize || 50,458 jobExecutionId: params.id,459 onlyKeywords: params.onlyKeywords,460 ignoreKeywords: params.ignoreKeywords,461 lastRows: params.lastRows462 },463 {464 method: "GET",465 }466 );467}468// 获取分区信息469export const getPartitionInfo = (params) => {470 if (!params.source) return471 const url = params.source.split(BASE_URL)[1]472 return request(473 `${url}?labels=${getEnvironment()}&dataSourceId=${params.dataSourceId}&database=${params.database}&table=${params.table}&_=${Math.random()}`,474 {},475 {476 method: "GET",477 }478 );...

Full Screen

Full Screen

get-environment-test.js

Source:get-environment-test.js Github

copy

Full Screen

...30};31module('Unit | Utility | getEnvironment', function() {32 test('it returns a function', function(assert) {33 const config = {};34 const env = getEnvironment(config, win, doc);35 assert.ok(typeof env === 'function');36 });37 test('it returns the correct operator value', function(assert) {38 const config = {};39 const env = getEnvironment(config, win, doc);40 assert.equal(env('CONSUL_HTTP_PROTOCOL'), 'spdy');41 });42 test('it returns the correct operator value when set via config', function(assert) {43 const config = {44 CONSUL_HTTP_PROTOCOL: 'hq',45 };46 const env = getEnvironment(config, win, doc);47 assert.equal(env('CONSUL_HTTP_PROTOCOL'), 'hq');48 });49 test('it returns the correct max connections depending on protocol', function(assert) {50 let config = {51 CONSUL_HTTP_PROTOCOL: 'hq',52 };53 let env = getEnvironment(config, win, doc);54 assert.equal(env('CONSUL_HTTP_MAX_CONNECTIONS'), undefined);55 config = {56 CONSUL_HTTP_PROTOCOL: 'http/1.1',57 };58 env = getEnvironment(config, win, doc);59 assert.equal(env('CONSUL_HTTP_MAX_CONNECTIONS'), 5);60 });61 test('it returns the correct max connections if performance.getEntriesByType is not available', function(assert) {62 const config = {};63 let win = {};64 let env = getEnvironment(config, win, doc);65 assert.equal(env('CONSUL_HTTP_MAX_CONNECTIONS'), 5);66 win = {67 performance: {},68 };69 env = getEnvironment(config, win, doc);70 assert.equal(env('CONSUL_HTTP_MAX_CONNECTIONS'), 5);71 });72 test('it returns the correct user value', function(assert) {73 const config = {};74 let win = {75 localStorage: {76 getItem: function(key) {77 return '1';78 },79 },80 };81 let env = getEnvironment(config, win, doc);82 assert.ok(env('CONSUL_UI_DISABLE_REALTIME'));83 win = {84 localStorage: {85 getItem: function(key) {86 return '0';87 },88 },89 };90 env = getEnvironment(config, win, doc);91 assert.notOk(env('CONSUL_UI_DISABLE_REALTIME'));92 win = {93 localStorage: {94 getItem: function(key) {95 return null;96 },97 },98 };99 env = getEnvironment(config, win, doc);100 assert.notOk(env('CONSUL_UI_DISABLE_REALTIME'));101 });102 test('it returns the correct user value when set via config', function(assert) {103 const config = {104 CONSUL_UI_DISABLE_REALTIME: true,105 };106 const env = getEnvironment(config, win, doc);107 assert.ok(env('CONSUL_UI_DISABLE_REALTIME'));108 });109 test('it returns the correct dev value (via cookies)', function(assert) {110 let config = {111 environment: 'test',112 CONSUL_NSPACES_ENABLED: false,113 };114 let doc = {115 cookie: 'CONSUL_NSPACES_ENABLE=1',116 getElementsByTagName: getElementsByTagName,117 };118 let env = getEnvironment(config, win, doc);119 assert.ok(env('CONSUL_NSPACES_ENABLED'));120 config = {121 environment: 'test',122 CONSUL_NSPACES_ENABLED: true,123 };124 doc = {125 cookie: 'CONSUL_NSPACES_ENABLE=0',126 getElementsByTagName: getElementsByTagName,127 };128 env = getEnvironment(config, win, doc);129 assert.notOk(env('CONSUL_NSPACES_ENABLED'));130 });131 test('it returns the correct dev value when set via config', function(assert) {132 let config = {133 CONSUL_NSPACES_ENABLED: true,134 };135 let env = getEnvironment(config, win, doc);136 assert.ok(env('CONSUL_NSPACES_ENABLED'));137 config = {138 CONSUL_NSPACES_ENABLED: false,139 };140 env = getEnvironment(config, win, doc);141 assert.notOk(env('CONSUL_NSPACES_ENABLED'));142 });143 test("it returns the correct dev value (ignoring cookies when the environment doesn't allow it)", function(assert) {144 let config = {145 environment: 'production',146 CONSUL_NSPACES_ENABLED: false,147 };148 let doc = {149 cookie: 'CONSUL_NSPACES_ENABLE=1',150 getElementsByTagName: getElementsByTagName,151 };152 let env = getEnvironment(config, win, doc);153 assert.notOk(env('CONSUL_NSPACES_ENABLED'));154 config = {155 environment: 'production',156 CONSUL_NSPACES_ENABLED: true,157 };158 doc = {159 cookie: 'CONSUL_NSPACES_ENABLE=0',160 getElementsByTagName: getElementsByTagName,161 };162 env = getEnvironment(config, win, doc);163 assert.ok(env('CONSUL_NSPACES_ENABLED'));164 });...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful