-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathupgrade-risks-prediction.test.ts
More file actions
77 lines (76 loc) · 2.34 KB
/
Copy pathupgrade-risks-prediction.test.ts
File metadata and controls
77 lines (76 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Copyright Contributors to the Open Cluster Management project */
import nock from 'nock'
import { parsePipedJsonBody } from '../../src/lib/body-parser'
import { request } from '../mock-request'
describe('Upgrade risks prediction Route', function () {
it('should return the upgrade risks', async function () {
nock(process.env.CLUSTER_API_URL).get('/api').reply(200)
nock(process.env.CLUSTER_API_URL)
.get('/api/v1/namespaces/openshift-config/secrets')
.reply(200, {
statusCode: 200,
body: {
apiVersion: 'v1',
kind: 'SecretList',
items: [
{
kind: 'Secret',
apiVersion: 'v1',
metadata: {
name: 'pull-secret',
namespace: 'openshift-config',
},
data: {
'.dockerconfigjson': 'test',
},
type: 'kubernetes.io/dockerconfigjson',
},
],
},
})
nock('https://console.redhat.com')
.post('/api/insights-results-aggregator/v2/upgrade-risks-prediction')
.reply(200, {
statusCode: 200,
body: {
predictions: [
{
cluster_id: 'id-1234-abcd',
prediction_status: 'ok',
upgrade_recommended: true,
upgrade_risks_predictors: {
alerts: [],
operator_conditions: [],
},
last_checked_at: '2024-03-25T20:33:03.156633+00:00',
},
],
status: 'ok',
},
})
const res = await request('POST', '/upgrade-risks-prediction', { clusterIds: ['id-1234-abcd'] })
expect(res.statusCode).toEqual(200)
expect(JSON.stringify(await parsePipedJsonBody(res))).toEqual(
JSON.stringify([
{
statusCode: 200,
body: {
statusCode: 200,
body: {
predictions: [
{
cluster_id: 'id-1234-abcd',
prediction_status: 'ok',
upgrade_recommended: true,
upgrade_risks_predictors: { alerts: [], operator_conditions: [] },
last_checked_at: '2024-03-25T20:33:03.156633+00:00',
},
],
status: 'ok',
},
},
},
])
)
})
})