1
+ import { fail } from 'assert' ;
1
2
import { expect } from 'chai' ;
2
3
import nock = require( 'nock' ) ;
3
4
import { V1APIResource , V1APIResourceList , V1Secret } from './api' ;
@@ -897,7 +898,11 @@ describe('KubernetesObject', () => {
897
898
expect . fail ( 'should have thrown error' ) ;
898
899
} catch ( e ) {
899
900
thrown = true ;
900
- expect ( e . message ) . to . equal ( 'Required spec property kind is not set' ) ;
901
+ if ( e instanceof Error ) {
902
+ expect ( e . message ) . to . equal ( 'Required spec property kind is not set' ) ;
903
+ } else {
904
+ fail ( `unknown exception: ${ e } ` ) ;
905
+ }
901
906
}
902
907
expect ( thrown ) . to . be . true ;
903
908
} ) ;
@@ -920,7 +925,11 @@ describe('KubernetesObject', () => {
920
925
expect . fail ( 'should have thrown error' ) ;
921
926
} catch ( e ) {
922
927
thrown = true ;
923
- expect ( e . message ) . to . equal ( 'Required spec property name is not set' ) ;
928
+ if ( e instanceof Error ) {
929
+ expect ( e . message ) . to . equal ( 'Required spec property name is not set' ) ;
930
+ } else {
931
+ fail ( `unknown exception: ${ e } ` ) ;
932
+ }
924
933
}
925
934
expect ( thrown ) . to . be . true ;
926
935
scope . done ( ) ;
@@ -945,7 +954,11 @@ describe('KubernetesObject', () => {
945
954
expect . fail ( 'should have thrown error' ) ;
946
955
} catch ( e ) {
947
956
thrown = true ;
948
- expect ( e . message ) . to . equal ( 'Unrecognized API version and kind: v1 Ingress' ) ;
957
+ if ( e instanceof Error ) {
958
+ expect ( e . message ) . to . equal ( 'Unrecognized API version and kind: v1 Ingress' ) ;
959
+ } else {
960
+ fail ( `unknown exception: ${ e } ` ) ;
961
+ }
949
962
}
950
963
expect ( thrown ) . to . be . true ;
951
964
scope . done ( ) ;
@@ -1005,9 +1018,13 @@ describe('KubernetesObject', () => {
1005
1018
await client . resource ( ( a as unknown ) as string , 'Service' ) ;
1006
1019
} catch ( e ) {
1007
1020
thrown = true ;
1008
- expect ( e . message ) . to . equal (
1009
- 'Required parameter apiVersion was null or undefined when calling resource' ,
1010
- ) ;
1021
+ if ( e instanceof Error ) {
1022
+ expect ( e . message ) . to . equal (
1023
+ 'Required parameter apiVersion was null or undefined when calling resource' ,
1024
+ ) ;
1025
+ } else {
1026
+ fail ( `unknown exception: ${ e } ` ) ;
1027
+ }
1011
1028
}
1012
1029
expect ( thrown ) . to . be . true ;
1013
1030
}
@@ -1020,9 +1037,13 @@ describe('KubernetesObject', () => {
1020
1037
await client . resource ( 'v1' , ( a as unknown ) as string ) ;
1021
1038
} catch ( e ) {
1022
1039
thrown = true ;
1023
- expect ( e . message ) . to . equal (
1024
- 'Required parameter kind was null or undefined when calling resource' ,
1025
- ) ;
1040
+ if ( e instanceof Error ) {
1041
+ expect ( e . message ) . to . equal (
1042
+ 'Required parameter kind was null or undefined when calling resource' ,
1043
+ ) ;
1044
+ } else {
1045
+ fail ( `unknown exception: ${ e } ` ) ;
1046
+ }
1026
1047
}
1027
1048
expect ( thrown ) . to . be . true ;
1028
1049
}
@@ -1920,9 +1941,13 @@ describe('KubernetesObject', () => {
1920
1941
expect . fail ( 'should have thrown an error' ) ;
1921
1942
} catch ( e ) {
1922
1943
thrown = true ;
1923
- expect ( e . message ) . to . contain (
1924
- 'Required parameter spec was null or undefined when calling ' ,
1925
- ) ;
1944
+ if ( e instanceof Error ) {
1945
+ expect ( e . message ) . to . contain (
1946
+ 'Required parameter spec was null or undefined when calling ' ,
1947
+ ) ;
1948
+ } else {
1949
+ fail ( `unknown exception: ${ e } ` ) ;
1950
+ }
1926
1951
}
1927
1952
expect ( thrown ) . to . be . true ;
1928
1953
}
@@ -1957,7 +1982,11 @@ describe('KubernetesObject', () => {
1957
1982
expect . fail ( 'should have thrown error' ) ;
1958
1983
} catch ( e ) {
1959
1984
thrown = true ;
1960
- expect ( e . message ) . to . contain ( 'Nock: No match for request' ) ;
1985
+ if ( e instanceof Error ) {
1986
+ expect ( e . message ) . to . contain ( 'Nock: No match for request' ) ;
1987
+ } else {
1988
+ fail ( `unknown exception: ${ e } ` ) ;
1989
+ }
1961
1990
}
1962
1991
expect ( thrown ) . to . be . true ;
1963
1992
} ) ;
@@ -2015,8 +2044,12 @@ describe('KubernetesObject', () => {
2015
2044
await client . create ( s ) ;
2016
2045
} catch ( e ) {
2017
2046
thrown = true ;
2018
- expect ( e . statusCode ) . to . equal ( 422 ) ;
2019
- expect ( e . message ) . to . equal ( 'HTTP request failed' ) ;
2047
+ if ( e instanceof Error ) {
2048
+ expect ( ( e as any ) . statusCode ) . to . equal ( 422 ) ;
2049
+ expect ( e . message ) . to . equal ( 'HTTP request failed' ) ;
2050
+ } else {
2051
+ fail ( `unknown exception: ${ e } ` ) ;
2052
+ }
2020
2053
}
2021
2054
expect ( thrown ) . to . be . true ;
2022
2055
scope . done ( ) ;
@@ -2064,10 +2097,14 @@ describe('KubernetesObject', () => {
2064
2097
await client . create ( d ) ;
2065
2098
} catch ( e ) {
2066
2099
thrown = true ;
2067
- expect ( e . statusCode ) . to . equal ( 404 ) ;
2068
- expect ( e . message ) . to . equal (
2069
- 'Failed to fetch resource metadata for applications/v1/Deployment: HTTP request failed' ,
2070
- ) ;
2100
+ if ( e instanceof Error ) {
2101
+ expect ( ( e as any ) . statusCode ) . to . equal ( 404 ) ;
2102
+ expect ( e . message ) . to . equal (
2103
+ 'Failed to fetch resource metadata for applications/v1/Deployment: HTTP request failed' ,
2104
+ ) ;
2105
+ } else {
2106
+ fail ( `unknown exception: ${ e } ` ) ;
2107
+ }
2071
2108
}
2072
2109
expect ( thrown ) . to . be . true ;
2073
2110
scope . done ( ) ;
@@ -2080,9 +2117,13 @@ describe('KubernetesObject', () => {
2080
2117
expect . fail ( 'should have thrown an error' ) ;
2081
2118
} catch ( e ) {
2082
2119
thrown = true ;
2083
- expect ( e . message ) . to . contain (
2084
- 'Required parameter apiVersion was null or undefined when calling ' ,
2085
- ) ;
2120
+ if ( e instanceof Error ) {
2121
+ expect ( e . message ) . to . contain (
2122
+ 'Required parameter apiVersion was null or undefined when calling ' ,
2123
+ ) ;
2124
+ } else {
2125
+ fail ( `unknown exception: ${ e } ` ) ;
2126
+ }
2086
2127
}
2087
2128
expect ( thrown ) . to . be . true ;
2088
2129
} ) ;
@@ -2094,7 +2135,13 @@ describe('KubernetesObject', () => {
2094
2135
expect . fail ( 'should have thrown an error' ) ;
2095
2136
} catch ( e ) {
2096
2137
thrown = true ;
2097
- expect ( e . message ) . to . contain ( 'Required parameter kind was null or undefined when calling ' ) ;
2138
+ if ( e instanceof Error ) {
2139
+ expect ( e . message ) . to . contain (
2140
+ 'Required parameter kind was null or undefined when calling ' ,
2141
+ ) ;
2142
+ } else {
2143
+ fail ( `unknown exception: ${ e } ` ) ;
2144
+ }
2098
2145
}
2099
2146
expect ( thrown ) . to . be . true ;
2100
2147
} ) ;
0 commit comments