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 1
1
import { expect } from 'chai' ;
2
2
import nock = require( 'nock' ) ;
3
- import { V1APIResource , V1APIResourceList } from './api' ;
3
+ import { V1APIResource , V1APIResourceList , V1Secret } from './api' ;
4
4
import { KubeConfig } from './config' ;
5
5
import { KubernetesObjectApi } from './object' ;
6
6
import { KubernetesObject } from './types' ;
@@ -1748,6 +1748,42 @@ describe('KubernetesObject', () => {
1748
1748
scope . done ( ) ;
1749
1749
} ) ;
1750
1750
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
+
1751
1787
it ( 'should list resources in a namespace' , async ( ) => {
1752
1788
const scope = nock ( 'https://d.i.y' )
1753
1789
. get (
You can’t perform that action at this time.
0 commit comments