1
1
import { deepEqual , deepStrictEqual , notStrictEqual , rejects , strictEqual , throws } from 'node:assert' ;
2
+ import child_process from 'node:child_process' ;
2
3
import { readFileSync } from 'node:fs' ;
3
4
import https from 'node:https' ;
4
5
import { Agent , RequestOptions } from 'node:https' ;
5
6
import path , { dirname , join } from 'node:path' ;
6
7
import { fileURLToPath } from 'node:url' ;
8
+ import { mock } from 'node:test' ;
7
9
8
10
import mockfs from 'mock-fs' ;
9
11
@@ -324,7 +326,6 @@ describe('KubeConfig', () => {
324
326
} ;
325
327
326
328
assertRequestOptionsEqual ( opts , expectedOptions ) ;
327
- console . log ( requestContext . getAgent ( ) ) ;
328
329
strictEqual ( ( requestContext . getAgent ( ) ! as any ) . options . servername , 'kube.example2.com' ) ;
329
330
} ) ;
330
331
it ( 'should apply cert configs' , async ( ) => {
@@ -1637,10 +1638,10 @@ describe('KubeConfig', () => {
1637
1638
it ( 'should try to load from WSL on Windows with wsl.exe not working' , ( ) => {
1638
1639
const kc = new KubeConfig ( ) ;
1639
1640
const commands : { command : string ; args : string [ ] } [ ] = [ ] ;
1640
- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1641
+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
1641
1642
commands . push ( { command : cmd , args } ) ;
1642
1643
return { status : 1 , stderr : 'some error' } ;
1643
- } ;
1644
+ } ) ;
1644
1645
kc . loadFromDefault ( undefined , false , 'win32' ) ;
1645
1646
strictEqual ( commands . length , 2 ) ;
1646
1647
for ( let i = 0 ; i < commands . length ; i ++ ) {
@@ -1657,10 +1658,10 @@ describe('KubeConfig', () => {
1657
1658
{ status : 0 , stderr : '' , stdout : configData . toString ( ) } ,
1658
1659
] ;
1659
1660
let ix = 0 ;
1660
- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1661
+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
1661
1662
commands . push ( { command : cmd , args } ) ;
1662
1663
return results [ ix ++ ] ;
1663
- } ;
1664
+ } ) ;
1664
1665
kc . loadFromDefault ( undefined , false , 'win32' ) ;
1665
1666
strictEqual ( commands . length , 2 ) ;
1666
1667
for ( let i = 0 ; i < commands . length ; i ++ ) {
@@ -1678,10 +1679,10 @@ describe('KubeConfig', () => {
1678
1679
{ status : 0 , stderr : '' , stdout : 'C:\\wsldata\\.kube' } ,
1679
1680
] ;
1680
1681
let ix = 0 ;
1681
- ( kc as any ) . spawnSync = ( cmd : string , args : string [ ] ) => {
1682
+ mock . method ( child_process , ' spawnSync' , ( cmd : string , args : string [ ] ) => {
1682
1683
commands . push ( { command : cmd , args } ) ;
1683
1684
return results [ ix ++ ] ;
1684
- } ;
1685
+ } ) ;
1685
1686
kc . loadFromDefault ( undefined , false , 'win32' ) ;
1686
1687
strictEqual ( commands . length , 3 ) ;
1687
1688
for ( let i = 0 ; i < commands . length ; i ++ ) {
0 commit comments