File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 11import { expect } from 'chai' ;
22import nock = require( 'nock' ) ;
3- import { V1APIResource , V1APIResourceList } from './api' ;
3+ import { V1APIResource , V1APIResourceList , V1Secret } from './api' ;
44import { KubeConfig } from './config' ;
55import { KubernetesObjectApi } from './object' ;
66import { KubernetesObject } from './types' ;
@@ -1748,6 +1748,42 @@ describe('KubernetesObject', () => {
17481748 scope . done ( ) ;
17491749 } ) ;
17501750
1751+ it ( 'should read a resource' , async ( ) => {
1752+ const scope = nock ( 'https://d.i.y' )
1753+ . get (
1754+ '/api/v1/namespaces/default/secrets/test-secret-1' ,
1755+ )
1756+ . reply ( 200 , {
1757+ apiVersion : 'v1' ,
1758+ kind : 'Secret' ,
1759+ metadata : {
1760+ name : 'test-secret-1' ,
1761+ namespace : 'default' ,
1762+ uid : 'a4fd7a65-2af5-4ef1-a0bc-cb34a308b821' ,
1763+ creationTimestamp : '2022-01-01T00:00:00.000Z' ,
1764+ } ,
1765+ data : {
1766+ key : 'value' ,
1767+ } ,
1768+ } ) ;
1769+ const res = await client . read (
1770+ {
1771+ apiVersion : 'v1' ,
1772+ kind : 'Secret' ,
1773+ metadata : {
1774+ name : 'test-secret-1' ,
1775+ namespace : 'default' ,
1776+ } ,
1777+ } ,
1778+ ) ;
1779+ const secret = res . body as V1Secret ;
1780+ expect ( secret . data ) . to . contain ( {
1781+ key : 'value' ,
1782+ } ) ;
1783+ expect ( secret . metadata ?. creationTimestamp ) . to . equal ( new Date ( '2022-01-01T00:00:00.000Z' ) ) ;
1784+ scope . done ( ) ;
1785+ } ) ;
1786+
17511787 it ( 'should list resources in a namespace' , async ( ) => {
17521788 const scope = nock ( 'https://d.i.y' )
17531789 . get (
You can’t perform that action at this time.
0 commit comments