From c8349473261d1cb260833f577652e86d9f54cbd1 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Mon, 31 Oct 2022 12:27:18 +0100
Subject: [PATCH] test: reduce aws-machine-image snapshots (#18671)

---
 .../__snapshots__/index.spec.ts.snap          | 463 ------------------
 .../aws-machine-image/index.spec.ts           | 105 +++-
 2 files changed, 102 insertions(+), 466 deletions(-)
 delete mode 100644 lib/modules/datasource/aws-machine-image/__snapshots__/index.spec.ts.snap

diff --git a/lib/modules/datasource/aws-machine-image/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/aws-machine-image/__snapshots__/index.spec.ts.snap
deleted file mode 100644
index e76e3af483..0000000000
--- a/lib/modules/datasource/aws-machine-image/__snapshots__/index.spec.ts.snap
+++ /dev/null
@@ -1,463 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`modules/datasource/aws-machine-image/index getSortedAwsMachineImages() with 1 returned image 1`] = `
-[
-  {
-    "args": [
-      DescribeImagesCommand {
-        "input": {
-          "Filters": [
-            {
-              "Name": "owner-id",
-              "Values": [
-                "602401143452",
-              ],
-            },
-            {
-              "Name": "name",
-              "Values": [
-                "1image",
-              ],
-            },
-          ],
-        },
-        "middlewareStack": {
-          "add": [Function],
-          "addRelativeTo": [Function],
-          "applyToStack": [Function],
-          "clone": [Function],
-          "concat": [Function],
-          "remove": [Function],
-          "removeByTag": [Function],
-          "resolve": [Function],
-          "use": [Function],
-        },
-      },
-    ],
-    "callId": 1,
-    "callback": undefined,
-    "errorWithCallStack": [Error],
-    "exception": undefined,
-    "firstArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "1image",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "lastArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "1image",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "proxy": [Function],
-    "returnValue": Promise {},
-    "thisValue": EC2Client {
-      "config": {
-        "apiVersion": "2016-11-15",
-        "base64Decoder": [Function],
-        "base64Encoder": [Function],
-        "bodyLengthChecker": [Function],
-        "credentialDefaultProvider": [Function],
-        "credentials": [Function],
-        "customUserAgent": undefined,
-        "defaultUserAgentProvider": [Function],
-        "defaultsMode": [Function],
-        "disableHostPrefix": false,
-        "endpoint": [Function],
-        "isCustomEndpoint": false,
-        "logger": {},
-        "maxAttempts": [Function],
-        "region": [Function],
-        "regionInfoProvider": [Function],
-        "requestHandler": NodeHttpHandler {
-          "configProvider": Promise {},
-          "metadata": {
-            "handlerProtocol": "http/1.1",
-          },
-        },
-        "retryMode": [Function],
-        "retryStrategy": [Function],
-        "runtime": "node",
-        "serviceId": "EC2",
-        "sha256": [Function],
-        "signer": [Function],
-        "signingEscapePath": true,
-        "streamCollector": [Function],
-        "systemClockOffset": 0,
-        "tls": true,
-        "urlParser": [Function],
-        "useDualstackEndpoint": [Function],
-        "useFipsEndpoint": [Function],
-        "utf8Decoder": [Function],
-        "utf8Encoder": [Function],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-  },
-]
-`;
-
-exports[`modules/datasource/aws-machine-image/index getSortedAwsMachineImages() with 3 returned images 1`] = `
-[
-  {
-    "args": [
-      DescribeImagesCommand {
-        "input": {
-          "Filters": [
-            {
-              "Name": "owner-id",
-              "Values": [
-                "602401143452",
-              ],
-            },
-            {
-              "Name": "name",
-              "Values": [
-                "3images",
-              ],
-            },
-          ],
-        },
-        "middlewareStack": {
-          "add": [Function],
-          "addRelativeTo": [Function],
-          "applyToStack": [Function],
-          "clone": [Function],
-          "concat": [Function],
-          "remove": [Function],
-          "removeByTag": [Function],
-          "resolve": [Function],
-          "use": [Function],
-        },
-      },
-    ],
-    "callId": 0,
-    "callback": undefined,
-    "errorWithCallStack": [Error],
-    "exception": undefined,
-    "firstArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "3images",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "lastArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "3images",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "proxy": [Function],
-    "returnValue": Promise {},
-    "thisValue": EC2Client {
-      "config": {
-        "apiVersion": "2016-11-15",
-        "base64Decoder": [Function],
-        "base64Encoder": [Function],
-        "bodyLengthChecker": [Function],
-        "credentialDefaultProvider": [Function],
-        "credentials": [Function],
-        "customUserAgent": undefined,
-        "defaultUserAgentProvider": [Function],
-        "defaultsMode": [Function],
-        "disableHostPrefix": false,
-        "endpoint": [Function],
-        "isCustomEndpoint": false,
-        "logger": {},
-        "maxAttempts": [Function],
-        "region": [Function],
-        "regionInfoProvider": [Function],
-        "requestHandler": NodeHttpHandler {
-          "configProvider": Promise {},
-          "metadata": {
-            "handlerProtocol": "http/1.1",
-          },
-        },
-        "retryMode": [Function],
-        "retryStrategy": [Function],
-        "runtime": "node",
-        "serviceId": "EC2",
-        "sha256": [Function],
-        "signer": [Function],
-        "signingEscapePath": true,
-        "streamCollector": [Function],
-        "systemClockOffset": 0,
-        "tls": true,
-        "urlParser": [Function],
-        "useDualstackEndpoint": [Function],
-        "useFipsEndpoint": [Function],
-        "utf8Decoder": [Function],
-        "utf8Encoder": [Function],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-  },
-]
-`;
-
-exports[`modules/datasource/aws-machine-image/index getSortedAwsMachineImages() without returned images 1`] = `
-[
-  {
-    "args": [
-      DescribeImagesCommand {
-        "input": {
-          "Filters": [
-            {
-              "Name": "owner-id",
-              "Values": [
-                "602401143452",
-              ],
-            },
-            {
-              "Name": "name",
-              "Values": [
-                "noiamge",
-              ],
-            },
-          ],
-        },
-        "middlewareStack": {
-          "add": [Function],
-          "addRelativeTo": [Function],
-          "applyToStack": [Function],
-          "clone": [Function],
-          "concat": [Function],
-          "remove": [Function],
-          "removeByTag": [Function],
-          "resolve": [Function],
-          "use": [Function],
-        },
-      },
-    ],
-    "callId": 2,
-    "callback": undefined,
-    "errorWithCallStack": [Error],
-    "exception": undefined,
-    "firstArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "noiamge",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "lastArg": DescribeImagesCommand {
-      "input": {
-        "Filters": [
-          {
-            "Name": "owner-id",
-            "Values": [
-              "602401143452",
-            ],
-          },
-          {
-            "Name": "name",
-            "Values": [
-              "noiamge",
-            ],
-          },
-        ],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-    "proxy": [Function],
-    "returnValue": Promise {},
-    "thisValue": EC2Client {
-      "config": {
-        "apiVersion": "2016-11-15",
-        "base64Decoder": [Function],
-        "base64Encoder": [Function],
-        "bodyLengthChecker": [Function],
-        "credentialDefaultProvider": [Function],
-        "credentials": [Function],
-        "customUserAgent": undefined,
-        "defaultUserAgentProvider": [Function],
-        "defaultsMode": [Function],
-        "disableHostPrefix": false,
-        "endpoint": [Function],
-        "isCustomEndpoint": false,
-        "logger": {},
-        "maxAttempts": [Function],
-        "region": [Function],
-        "regionInfoProvider": [Function],
-        "requestHandler": NodeHttpHandler {
-          "configProvider": Promise {},
-          "metadata": {
-            "handlerProtocol": "http/1.1",
-          },
-        },
-        "retryMode": [Function],
-        "retryStrategy": [Function],
-        "runtime": "node",
-        "serviceId": "EC2",
-        "sha256": [Function],
-        "signer": [Function],
-        "signingEscapePath": true,
-        "streamCollector": [Function],
-        "systemClockOffset": 0,
-        "tls": true,
-        "urlParser": [Function],
-        "useDualstackEndpoint": [Function],
-        "useFipsEndpoint": [Function],
-        "utf8Decoder": [Function],
-        "utf8Encoder": [Function],
-      },
-      "middlewareStack": {
-        "add": [Function],
-        "addRelativeTo": [Function],
-        "applyToStack": [Function],
-        "clone": [Function],
-        "concat": [Function],
-        "remove": [Function],
-        "removeByTag": [Function],
-        "resolve": [Function],
-        "use": [Function],
-      },
-    },
-  },
-]
-`;
diff --git a/lib/modules/datasource/aws-machine-image/index.spec.ts b/lib/modules/datasource/aws-machine-image/index.spec.ts
index fffda991f6..2fcf26de7f 100644
--- a/lib/modules/datasource/aws-machine-image/index.spec.ts
+++ b/lib/modules/datasource/aws-machine-image/index.spec.ts
@@ -145,7 +145,40 @@ describe('modules/datasource/aws-machine-image/index', () => {
         '[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["3images"]}]'
       );
       expect(res).toStrictEqual([image1, image2, image3]);
-      expect(ec2Mock.calls()).toMatchSnapshot();
+      expect(ec2Mock.calls()).toHaveLength(1);
+      expect(ec2Mock.calls()[0].args).toMatchInlineSnapshot(`
+        [
+          DescribeImagesCommand {
+            "input": {
+              "Filters": [
+                {
+                  "Name": "owner-id",
+                  "Values": [
+                    "602401143452",
+                  ],
+                },
+                {
+                  "Name": "name",
+                  "Values": [
+                    "3images",
+                  ],
+                },
+              ],
+            },
+            "middlewareStack": {
+              "add": [Function],
+              "addRelativeTo": [Function],
+              "applyToStack": [Function],
+              "clone": [Function],
+              "concat": [Function],
+              "remove": [Function],
+              "removeByTag": [Function],
+              "resolve": [Function],
+              "use": [Function],
+            },
+          },
+        ]
+      `);
     });
 
     it('with 1 returned image', async () => {
@@ -155,7 +188,40 @@ describe('modules/datasource/aws-machine-image/index', () => {
         '[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["1image"]}]'
       );
       expect(res).toStrictEqual([image3]);
-      expect(ec2Mock.calls()).toMatchSnapshot();
+      expect(ec2Mock.calls()).toHaveLength(1);
+      expect(ec2Mock.calls()[0].args).toMatchInlineSnapshot(`
+        [
+          DescribeImagesCommand {
+            "input": {
+              "Filters": [
+                {
+                  "Name": "owner-id",
+                  "Values": [
+                    "602401143452",
+                  ],
+                },
+                {
+                  "Name": "name",
+                  "Values": [
+                    "1image",
+                  ],
+                },
+              ],
+            },
+            "middlewareStack": {
+              "add": [Function],
+              "addRelativeTo": [Function],
+              "applyToStack": [Function],
+              "clone": [Function],
+              "concat": [Function],
+              "remove": [Function],
+              "removeByTag": [Function],
+              "resolve": [Function],
+              "use": [Function],
+            },
+          },
+        ]
+      `);
     });
 
     it('without returned images', async () => {
@@ -165,7 +231,40 @@ describe('modules/datasource/aws-machine-image/index', () => {
         '[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["noiamge"]}]'
       );
       expect(res).toStrictEqual([]);
-      expect(ec2Mock.calls()).toMatchSnapshot();
+      expect(ec2Mock.calls()).toHaveLength(1);
+      expect(ec2Mock.calls()[0].args).toMatchInlineSnapshot(`
+        [
+          DescribeImagesCommand {
+            "input": {
+              "Filters": [
+                {
+                  "Name": "owner-id",
+                  "Values": [
+                    "602401143452",
+                  ],
+                },
+                {
+                  "Name": "name",
+                  "Values": [
+                    "noiamge",
+                  ],
+                },
+              ],
+            },
+            "middlewareStack": {
+              "add": [Function],
+              "addRelativeTo": [Function],
+              "applyToStack": [Function],
+              "clone": [Function],
+              "concat": [Function],
+              "remove": [Function],
+              "removeByTag": [Function],
+              "resolve": [Function],
+              "use": [Function],
+            },
+          },
+        ]
+      `);
     });
   });
 
-- 
GitLab