From 6da5d4df64063c4c7cad41c7109e0c5ae449d3f2 Mon Sep 17 00:00:00 2001 From: John Boyes Date: Wed, 15 Jul 2020 12:39:13 +0700 Subject: [PATCH] Install Hoverfly on devcontainer for virtual tests Also added and trusted the Hoverfly default certificate[1], so that Hoverfly https calls work And also set the tests to run in verbose mode in Visual Studio Code, so we get more informative output when running them. [1] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem https://hoverfly.readthedocs.io/ --- .devcontainer/Dockerfile | 22 ++++++++++++++++++++++ .vscode/settings.json | 1 + 2 files changed, 23 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b5f3f899..ebbcc159 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -18,6 +18,8 @@ ARG USER_GID=$USER_UID RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + # Need zip and unzip for the Hoverfly installation + && apt-get -y install --no-install-recommends zip unzip \ # # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed && apt-get -y install --no-install-recommends git openssh-client less iproute2 procps lsb-release \ @@ -63,3 +65,23 @@ RUN apt-get update \ # Updated from "auto" to "on" as we are using Go modules for this project # See https://dev.to/maelvls/why-is-go111module-everywhere-and-everything-about-go-modules-24k ENV GO111MODULE=on + +# Install Hoverfly for virtualised tests: https://hoverfly.readthedocs.io/ +# hadolint ignore=DL3003 +RUN mkdir -p /tmp/hoverfly \ + && cd /tmp/hoverfly || exit \ + && export HOVERFLY_PLATFORM=linux_amd64 \ + && export HOVERFLY_PLATFORM=linux_amd64 \ + && export HOVERFLY_VERSION=v1.3.0 \ + && export HOVERFLY_BUNDLE=hoverfly_bundle_$HOVERFLY_PLATFORM \ + && wget https://github.com/SpectoLabs/hoverfly/releases/download/$HOVERFLY_VERSION/$HOVERFLY_BUNDLE.zip \ + && unzip $HOVERFLY_BUNDLE.zip \ + && mv hoverfly /usr/local/bin/ \ + && mv hoverctl /usr/local/bin/ \ + && chmod +x /usr/local/bin/hoverfly \ + && chmod +x /usr/local/bin/hoverctl \ + # Add the trusted Hoverfly certificate so that Hoverfly SSL calls work + && wget https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem \ + && cp cert.pem /usr/local/share/ca-certificates/hoverfly.crt \ + && update-ca-certificates \ + && rm -rf /tmp/hoverfly diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a4f67d3..d4b4eeec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,6 +21,7 @@ "go.lintOnSave": "file", "go.testTimeout": "240s", "go.testEnvFile": "${workspaceFolder}/.env", + "go.testFlags": ["-v"], // "VSCode will complain about the "gopls" settings, but they will still work. // Once we have a consistent set of settings, we will make the changes in the