pepr 0.3.0-rc0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,333 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
-
4
- import test from "ava";
5
- import { a, modelToGroupVersionKind } from ".";
6
-
7
- test("should return the correct GroupVersionKind for 'a.V1APIService'", t => {
8
- const { name } = a.APIService;
9
- const gvk = modelToGroupVersionKind(name);
10
- t.is(gvk.group, "apiregistration.k8s.io");
11
- t.is(gvk.version, "v1");
12
- t.is(gvk.kind, "APIService");
13
- });
14
-
15
- test("should return the correct GroupVersionKind for 'a.V1CertificateSigningRequest'", t => {
16
- const { name } = a.CertificateSigningRequest;
17
- const gvk = modelToGroupVersionKind(name);
18
- t.is(gvk.group, "certificates.k8s.io");
19
- t.is(gvk.version, "v1");
20
- t.is(gvk.kind, "CertificateSigningRequest");
21
- });
22
-
23
- test("should return the correct GroupVersionKind for 'a.V1ConfigMap'", t => {
24
- const { name } = a.ConfigMap;
25
- const gvk = modelToGroupVersionKind(name);
26
- t.is(gvk.group, "");
27
- t.is(gvk.version, "v1");
28
- t.is(gvk.kind, "ConfigMap");
29
- });
30
-
31
- test("should return the correct GroupVersionKind for 'a.V1ControllerRevision'", t => {
32
- const { name } = a.ControllerRevision;
33
- const gvk = modelToGroupVersionKind(name);
34
- t.is(gvk.group, "apps");
35
- t.is(gvk.version, "v1");
36
- t.is(gvk.kind, "ControllerRevision");
37
- });
38
-
39
- test("should return the correct GroupVersionKind for 'a.V1CronJob'", t => {
40
- const { name } = a.CronJob;
41
- const gvk = modelToGroupVersionKind(name);
42
- t.is(gvk.group, "batch");
43
- t.is(gvk.version, "v1");
44
- t.is(gvk.kind, "CronJob");
45
- });
46
-
47
- test("should return the correct GroupVersionKind for 'a.V1CSIDriver'", t => {
48
- const { name } = a.CSIDriver;
49
- const gvk = modelToGroupVersionKind(name);
50
- t.is(gvk.group, "storage.k8s.io");
51
- t.is(gvk.version, "v1");
52
- t.is(gvk.kind, "CSIDriver");
53
- });
54
-
55
- test("should return the correct GroupVersionKind for 'a.V1CSIStorageCapacity'", t => {
56
- const { name } = a.CSIStorageCapacity;
57
- const gvk = modelToGroupVersionKind(name);
58
- t.is(gvk.group, "storage.k8s.io");
59
- t.is(gvk.version, "v1");
60
- t.is(gvk.kind, "CSIStorageCapacity");
61
- });
62
-
63
- test("should return the correct GroupVersionKind for 'a.V1CustomResourceDefinition'", t => {
64
- const { name } = a.CustomResourceDefinition;
65
- const gvk = modelToGroupVersionKind(name);
66
- t.is(gvk.group, "apiextensions.k8s.io");
67
- t.is(gvk.version, "v1");
68
- t.is(gvk.kind, "CustomResourceDefinition");
69
- });
70
-
71
- test("should return the correct GroupVersionKind for 'a.V1DaemonSet'", t => {
72
- const { name } = a.DaemonSet;
73
- const gvk = modelToGroupVersionKind(name);
74
- t.is(gvk.group, "apps");
75
- t.is(gvk.version, "v1");
76
- t.is(gvk.kind, "DaemonSet");
77
- });
78
-
79
- test("should return the correct GroupVersionKind for 'a.V1Deployment'", t => {
80
- const { name } = a.Deployment;
81
- const gvk = modelToGroupVersionKind(name);
82
- t.is(gvk.group, "apps");
83
- t.is(gvk.version, "v1");
84
- t.is(gvk.kind, "Deployment");
85
- });
86
-
87
- test("should return the correct GroupVersionKind for 'a.V1EndpointSlice'", t => {
88
- const { name } = a.EndpointSlice;
89
- const gvk = modelToGroupVersionKind(name);
90
- t.is(gvk.group, "discovery.k8s.io");
91
- t.is(gvk.version, "v1");
92
- t.is(gvk.kind, "EndpointSlice");
93
- });
94
-
95
- test("should return the correct GroupVersionKind for 'a.V1HorizontalPodAutoscaler'", t => {
96
- const { name } = a.HorizontalPodAutoscaler;
97
- const gvk = modelToGroupVersionKind(name);
98
- t.is(gvk.group, "autoscaling");
99
- t.is(gvk.version, "v2");
100
- t.is(gvk.kind, "HorizontalPodAutoscaler");
101
- });
102
-
103
- test("should return the correct GroupVersionKind for 'a.V1Ingress'", t => {
104
- const { name } = a.Ingress;
105
- const gvk = modelToGroupVersionKind(name);
106
- t.is(gvk.group, "networking.k8s.io");
107
- t.is(gvk.version, "v1");
108
- t.is(gvk.kind, "Ingress");
109
- });
110
-
111
- test("should return the correct GroupVersionKind for 'a.V1IngressClass'", t => {
112
- const { name } = a.IngressClass;
113
- const gvk = modelToGroupVersionKind(name);
114
- t.is(gvk.group, "networking.k8s.io");
115
- t.is(gvk.version, "v1");
116
- t.is(gvk.kind, "IngressClass");
117
- });
118
-
119
- test("should return the correct GroupVersionKind for 'a.V1Job'", t => {
120
- const { name } = a.Job;
121
- const gvk = modelToGroupVersionKind(name);
122
- t.is(gvk.group, "batch");
123
- t.is(gvk.version, "v1");
124
- t.is(gvk.kind, "Job");
125
- });
126
-
127
- test("should return the correct GroupVersionKind for 'a.V1LimitRange'", t => {
128
- const { name } = a.LimitRange;
129
- const gvk = modelToGroupVersionKind(name);
130
- t.is(gvk.group, "");
131
- t.is(gvk.version, "v1");
132
- t.is(gvk.kind, "LimitRange");
133
- });
134
-
135
- test("should return the correct GroupVersionKind for 'a.V1LocalSubjectAccessReview'", t => {
136
- const { name } = a.LocalSubjectAccessReview;
137
- const gvk = modelToGroupVersionKind(name);
138
- t.is(gvk.group, "authorization.k8s.io");
139
- t.is(gvk.version, "v1");
140
- t.is(gvk.kind, "LocalSubjectAccessReview");
141
- });
142
-
143
- test("should return the correct GroupVersionKind for 'a.V1MutatingWebhookConfiguration'", t => {
144
- const { name } = a.MutatingWebhookConfiguration;
145
- const gvk = modelToGroupVersionKind(name);
146
- t.is(gvk.group, "admissionregistration.k8s.io");
147
- t.is(gvk.version, "v1");
148
- t.is(gvk.kind, "MutatingWebhookConfiguration");
149
- });
150
-
151
- test("should return the correct GroupVersionKind for 'a.V1Namespace'", t => {
152
- const { name } = a.Namespace;
153
- const gvk = modelToGroupVersionKind(name);
154
- t.is(gvk.group, "");
155
- t.is(gvk.version, "v1");
156
- t.is(gvk.kind, "Namespace");
157
- });
158
-
159
- test("should return the correct GroupVersionKind for 'a.V1NetworkPolicy'", t => {
160
- const { name } = a.NetworkPolicy;
161
- const gvk = modelToGroupVersionKind(name);
162
- t.is(gvk.group, "networking.k8s.io");
163
- t.is(gvk.version, "v1");
164
- t.is(gvk.kind, "NetworkPolicy");
165
- });
166
-
167
- test("should return the correct GroupVersionKind for 'a.V1Node'", t => {
168
- const { name } = a.Node;
169
- const gvk = modelToGroupVersionKind(name);
170
- t.is(gvk.group, "");
171
- t.is(gvk.version, "v1");
172
- t.is(gvk.kind, "Node");
173
- });
174
-
175
- test("should return the correct GroupVersionKind for 'a.V1PersistentVolume'", t => {
176
- const { name } = a.PersistentVolume;
177
- const gvk = modelToGroupVersionKind(name);
178
- t.is(gvk.group, "");
179
- t.is(gvk.version, "v1");
180
- t.is(gvk.kind, "PersistentVolume");
181
- });
182
-
183
- test("should return the correct GroupVersionKind for 'a.V1PersistentVolumeClaim'", t => {
184
- const { name } = a.PersistentVolumeClaim;
185
- const gvk = modelToGroupVersionKind(name);
186
- t.is(gvk.group, "");
187
- t.is(gvk.version, "v1");
188
- t.is(gvk.kind, "PersistentVolumeClaim");
189
- });
190
-
191
- test("should return the correct GroupVersionKind for 'a.V1Pod'", t => {
192
- const { name } = a.Pod;
193
- const gvk = modelToGroupVersionKind(name);
194
- t.is(gvk.group, "");
195
- t.is(gvk.version, "v1");
196
- t.is(gvk.kind, "Pod");
197
- });
198
-
199
- test("should return the correct GroupVersionKind for 'a.V1PodDisruptionBudget'", t => {
200
- const { name } = a.PodDisruptionBudget;
201
- const gvk = modelToGroupVersionKind(name);
202
- t.is(gvk.group, "policy");
203
- t.is(gvk.version, "v1");
204
- t.is(gvk.kind, "PodDisruptionBudget");
205
- });
206
-
207
- test("should return the correct GroupVersionKind for 'a.V1PodTemplate'", t => {
208
- const { name } = a.PodTemplate;
209
- const gvk = modelToGroupVersionKind(name);
210
- t.is(gvk.group, "");
211
- t.is(gvk.version, "v1");
212
- t.is(gvk.kind, "PodTemplate");
213
- });
214
-
215
- test("should return the correct GroupVersionKind for 'a.V1ReplicaSet'", t => {
216
- const { name } = a.ReplicaSet;
217
- const gvk = modelToGroupVersionKind(name);
218
- t.is(gvk.group, "apps");
219
- t.is(gvk.version, "v1");
220
- t.is(gvk.kind, "ReplicaSet");
221
- });
222
-
223
- test("should return the correct GroupVersionKind for 'a.V1ReplicationController'", t => {
224
- const { name } = a.ReplicationController;
225
- const gvk = modelToGroupVersionKind(name);
226
- t.is(gvk.group, "");
227
- t.is(gvk.version, "v1");
228
- t.is(gvk.kind, "ReplicationController");
229
- });
230
-
231
- test("should return the correct GroupVersionKind for 'a.V1ResourceQuota'", t => {
232
- const { name } = a.ResourceQuota;
233
- const gvk = modelToGroupVersionKind(name);
234
- t.is(gvk.group, "");
235
- t.is(gvk.version, "v1");
236
- t.is(gvk.kind, "ResourceQuota");
237
- });
238
-
239
- test("should return the correct GroupVersionKind for 'a.V1RuntimeClass'", t => {
240
- const { name } = a.RuntimeClass;
241
- const gvk = modelToGroupVersionKind(name);
242
- t.is(gvk.group, "node.k8s.io");
243
- t.is(gvk.version, "v1");
244
- t.is(gvk.kind, "RuntimeClass");
245
- });
246
-
247
- test("should return the correct GroupVersionKind for 'a.V1Secret'", t => {
248
- const { name } = a.Secret;
249
- const gvk = modelToGroupVersionKind(name);
250
- t.is(gvk.group, "");
251
- t.is(gvk.version, "v1");
252
- t.is(gvk.kind, "Secret");
253
- });
254
-
255
- test("should return the correct GroupVersionKind for 'a.V1SelfSubjectAccessReview'", t => {
256
- const { name } = a.SelfSubjectAccessReview;
257
- const gvk = modelToGroupVersionKind(name);
258
- t.is(gvk.group, "authorization.k8s.io");
259
- t.is(gvk.version, "v1");
260
- t.is(gvk.kind, "SelfSubjectAccessReview");
261
- });
262
-
263
- test("should return the correct GroupVersionKind for 'a.V1SelfSubjectRulesReview'", t => {
264
- const { name } = a.SelfSubjectRulesReview;
265
- const gvk = modelToGroupVersionKind(name);
266
- t.is(gvk.group, "authorization.k8s.io");
267
- t.is(gvk.version, "v1");
268
- t.is(gvk.kind, "SelfSubjectRulesReview");
269
- });
270
-
271
- test("should return the correct GroupVersionKind for 'a.V1Service'", t => {
272
- const { name } = a.Service;
273
- const gvk = modelToGroupVersionKind(name);
274
- t.is(gvk.group, "");
275
- t.is(gvk.version, "v1");
276
- t.is(gvk.kind, "Service");
277
- });
278
-
279
- test("should return the correct GroupVersionKind for 'a.V1ServiceAccount'", t => {
280
- const { name } = a.ServiceAccount;
281
- const gvk = modelToGroupVersionKind(name);
282
- t.is(gvk.group, "");
283
- t.is(gvk.version, "v1");
284
- t.is(gvk.kind, "ServiceAccount");
285
- });
286
-
287
- test("should return the correct GroupVersionKind for 'a.V1StatefulSet'", t => {
288
- const { name } = a.StatefulSet;
289
- const gvk = modelToGroupVersionKind(name);
290
- t.is(gvk.group, "apps");
291
- t.is(gvk.version, "v1");
292
- t.is(gvk.kind, "StatefulSet");
293
- });
294
-
295
- test("should return the correct GroupVersionKind for 'a.V1StorageClass'", t => {
296
- const { name } = a.StorageClass;
297
- const gvk = modelToGroupVersionKind(name);
298
- t.is(gvk.group, "storage.k8s.io");
299
- t.is(gvk.version, "v1");
300
- t.is(gvk.kind, "StorageClass");
301
- });
302
-
303
- test("should return the correct GroupVersionKind for 'a.V1SubjectAccessReview'", t => {
304
- const { name } = a.SubjectAccessReview;
305
- const gvk = modelToGroupVersionKind(name);
306
- t.is(gvk.group, "authorization.k8s.io");
307
- t.is(gvk.version, "v1");
308
- t.is(gvk.kind, "SubjectAccessReview");
309
- });
310
-
311
- test("should return the correct GroupVersionKind for 'a.V1TokenReview'", t => {
312
- const { name } = a.TokenReview;
313
- const gvk = modelToGroupVersionKind(name);
314
- t.is(gvk.group, "authentication.k8s.io");
315
- t.is(gvk.version, "v1");
316
- t.is(gvk.kind, "TokenReview");
317
- });
318
-
319
- test("should return the correct GroupVersionKind for 'a.V1ValidatingWebhookConfiguration'", t => {
320
- const { name } = a.ValidatingWebhookConfiguration;
321
- const gvk = modelToGroupVersionKind(name);
322
- t.is(gvk.group, "admissionregistration.k8s.io");
323
- t.is(gvk.version, "v1");
324
- t.is(gvk.kind, "ValidatingWebhookConfiguration");
325
- });
326
-
327
- test("should return the correct GroupVersionKind for 'a.V1VolumeAttachment'", t => {
328
- const { name } = a.VolumeAttachment;
329
- const gvk = modelToGroupVersionKind(name);
330
- t.is(gvk.group, "storage.k8s.io");
331
- t.is(gvk.version, "v1");
332
- t.is(gvk.kind, "VolumeAttachment");
333
- });
@@ -1,80 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
-
4
- import test from "ava";
5
- import { LogLevel, Logger } from "./logger";
6
-
7
- test("Logger debug logs correctly", t => {
8
- const logger = new Logger(LogLevel.debug); // Create a logger with debug level
9
- const message = "Debug message";
10
- const consoleLog = console.log; // Store the original console.log function
11
- const consoleOutput: string[] = [];
12
-
13
- // Replace console.log with a mock function to capture the output
14
- console.log = (output: string) => {
15
- consoleOutput.push(output);
16
- };
17
-
18
- logger.debug(message); // Call the debug method
19
-
20
- // Check that the output matches the expected value
21
- t.true(consoleOutput[0].includes(LogLevel[LogLevel.debug]));
22
- t.true(consoleOutput[0].includes(message));
23
-
24
- // Restore the original console.log function
25
- console.log = consoleLog;
26
- });
27
-
28
- test("Logger info logs correctly", t => {
29
- const logger = new Logger(LogLevel.info); // Create a logger with info level
30
- const message = "Info message";
31
- const consoleLog = console.log;
32
- const consoleOutput: string[] = [];
33
-
34
- console.log = (output: string) => {
35
- consoleOutput.push(output);
36
- };
37
-
38
- logger.info(message);
39
-
40
- t.true(consoleOutput[0].includes(LogLevel[LogLevel.info]));
41
- t.true(consoleOutput[0].includes(message));
42
-
43
- console.log = consoleLog;
44
- });
45
-
46
- test("Logger warn logs correctly", t => {
47
- const logger = new Logger(LogLevel.warn); // Create a logger with warn level
48
- const message = "Warning message";
49
- const consoleLog = console.log;
50
- const consoleOutput: string[] = [];
51
-
52
- console.log = (output: string) => {
53
- consoleOutput.push(output);
54
- };
55
-
56
- logger.warn(message);
57
-
58
- t.true(consoleOutput[0].includes(LogLevel[LogLevel.warn]));
59
- t.true(consoleOutput[0].includes(message));
60
-
61
- console.log = consoleLog;
62
- });
63
-
64
- test("Logger error logs correctly", t => {
65
- const logger = new Logger(LogLevel.error); // Create a logger with error level
66
- const message = "Error message";
67
- const consoleLog = console.log;
68
- const consoleOutput: string[] = [];
69
-
70
- console.log = (output: string) => {
71
- consoleOutput.push(output);
72
- };
73
-
74
- logger.error(message);
75
-
76
- t.true(consoleOutput[0].includes(LogLevel[LogLevel.error]));
77
- t.true(consoleOutput[0].includes(message));
78
-
79
- console.log = consoleLog;
80
- });