@@ -39,6 +39,49 @@ describe('ClusterService', () => {
3939 } ) ;
4040 } ) ;
4141} ) ;
42+ describe ( 'ClusterService with tags' , ( ) => {
43+ beforeAll ( ( ) => globalThis . provider . setup ( ) ) ;
44+ afterEach ( ( ) => globalThis . provider . verify ( ) ) ;
45+ afterAll ( ( ) => globalThis . provider . finalize ( ) ) ;
46+ test ( 'should return cluster with tags' , ( ) => {
47+ const expectedCluster = { cluster : { name : "cluster1" , id : "1234abcd" , status : "provisioning" } } ;
48+ const reqBody = {
49+ name : "cluster1" ,
50+ kubernetes_distribution : "kind" ,
51+ kubernetes_version : "v1.25.1" ,
52+ ttl : "10m" ,
53+ tags : [
54+ {
55+ key : "foo" ,
56+ value : "bar"
57+ }
58+ ]
59+ } ;
60+ globalThis . provider . addInteraction ( {
61+ state : 'cluster created' ,
62+ uponReceiving : 'a request for creating a cluster' ,
63+ withRequest : {
64+ method : 'POST' ,
65+ path : '/cluster' ,
66+ body : reqBody ,
67+ } ,
68+ willRespondWith : {
69+ status : 201 ,
70+ headers : { 'Content-Type' : 'application/json' } ,
71+ body : expectedCluster
72+ }
73+ } ) ;
74+ const apiClient = new configuration_1 . VendorPortalApi ( ) ;
75+ apiClient . apiToken = "abcd1234" ;
76+ apiClient . endpoint = globalThis . provider . mockService . baseUrl ;
77+ const tags = [ { key : "foo" , value : "bar" } ] ;
78+ return ( 0 , clusters_1 . createCluster ) ( apiClient , "cluster1" , "kind" , "v1.25.1" , "10m" , undefined , undefined , undefined , tags ) . then ( cluster => {
79+ expect ( cluster . name ) . toEqual ( expectedCluster . cluster . name ) ;
80+ expect ( cluster . id ) . toEqual ( expectedCluster . cluster . id ) ;
81+ expect ( cluster . status ) . toEqual ( expectedCluster . cluster . status ) ;
82+ } ) ;
83+ } ) ;
84+ } ) ;
4285describe ( 'upgradeCluster' , ( ) => {
4386 const mockServer = mockttp . getLocal ( ) ;
4487 const apiClient = new configuration_1 . VendorPortalApi ( ) ;
0 commit comments