@@ -3,7 +3,7 @@ const axios = require('axios');
33const constants = require ( "./utils/constants.js" ) ;
44const process = require ( "process" ) ;
55const fs = require ( "fs" ) ;
6- function stop_session ( args ) {
6+ function stop_build ( args ) {
77 return new Promise ( function ( resolve , reject ) {
88 var username = "" ;
99 var access_key = "" ;
@@ -26,33 +26,33 @@ function stop_session(args) {
2626 } else {
2727 reject ( "Access Key not provided" ) ;
2828 }
29- if ( "stop_last_session " in args ) {
29+ if ( "stop_last_build " in args ) {
3030 const file_path = "lambdatest_run.json" ;
3131 if ( fs . existsSync ( file_path ) ) {
3232 let lambda_run = fs . readFileSync ( file_path ) ;
3333 try {
3434 let lambda_run_obj = JSON . parse ( lambda_run ) ;
35- if ( ! ( "session_id " in lambda_run_obj ) ) {
36- throw new Error ( "session_id is missing from the file" ) ;
35+ if ( ! ( "build_id " in lambda_run_obj ) ) {
36+ throw new Error ( "build_id is missing from the file" ) ;
3737 }
38- args . session_id = lambda_run_obj . session_id ;
38+ args . build_id = lambda_run_obj . build_id ;
3939 } catch ( e ) {
4040 reject (
4141 "Error!! lambdatest_run.json file is tampered Err: " + e . message
4242 ) ;
4343 }
4444 } else {
4545 reject (
46- "Error!! Last session details not found, lambdatest_run.json file not present!!"
46+ "Error!! Last Build details not found, lambdatest_run.json file not present!!"
4747 ) ;
4848 }
4949 } else {
5050 if (
51- ! ( "session_id " in args ) ||
52- args [ "session_id " ] == "" ||
53- args [ "session_id " ] == undefined
51+ ! ( "build_id " in args ) ||
52+ args [ "build_id " ] == "" ||
53+ args [ "build_id " ] == undefined
5454 ) {
55- reject ( "Error!! Please provide a Session ID" ) ;
55+ reject ( "Error!! Please provide a Build ID" ) ;
5656 }
5757 }
5858 var env = "prod" ;
@@ -68,7 +68,7 @@ function stop_session(args) {
6868
6969 let options = {
7070 method : 'put' ,
71- url : constants [ env ] . BUILD_STOP_URL + args . session_id ,
71+ url : constants [ env ] . BUILD_STOP_URL + "?buildId=" + args . build_id ,
7272 headers : {
7373 Authorization : "Token " + access_key ,
7474 Username : username ,
@@ -93,10 +93,10 @@ function stop_session(args) {
9393 axios ( options )
9494 . then ( response => {
9595 if ( response . data . length == 0 ) {
96- resolve ( "No tests to stop in session " + args . session_id ) ;
96+ resolve ( "No tests to stop in build " + args . build_id ) ;
9797 } else {
9898 resolve (
99- "Session Stopped successfully, No. of tests stopped are: " +
99+ "Build Stopped successfully, No. of tests stopped are: " +
100100 response . data . length
101101 ) ;
102102 }
@@ -120,7 +120,7 @@ function stop_session(args) {
120120}
121121
122122module . exports = function ( args ) {
123- stop_session ( args )
123+ stop_build ( args )
124124 . then ( function ( resp ) {
125125 console . log ( resp ) ;
126126 } )
0 commit comments