diff --git a/README.md b/README.md index 1636255..ef6d438 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,16 @@ time=05/23/22 level=info msg="124 MB of storage space will be removed in an actu time=05/23/22 level=info msg="Job Duration Time: 1.454406s" ``` +### Nightly Release + +A nightly release is available as a Docker image. The nightly release is a snapshot of the main branch and automatically updated with the latest minor depedencies updates. + +```shell +docker pull ghcr.io/karl-cardenas-coding/go-lambda-cleanup:nightly +``` + + + ## Usage ```shell diff --git a/cmd/root_test.go b/cmd/root_test.go index 2d0e07b..cac296f 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -5,7 +5,9 @@ package cmd import ( "context" + "crypto/tls" "fmt" + "net/http" "os" "testing" @@ -371,3 +373,46 @@ func TestNoLambdas(t *testing.T) { }) } + +func TestCreateHTTPClient(t *testing.T) { + // Set an environment variable for the proxy + os.Setenv("HTTP_PROXY", "http://proxy.example.com") + defer os.Unsetenv("HTTP_PROXY") + + client := createHTTPClient() + + // Check if the client is not nil + if client == nil { + t.Fatalf("Expected non-nil HTTP client") + } + + // Check if the transport is of type *http.Transport + transport, ok := client.Transport.(*http.Transport) + if !ok { + t.Fatalf("Expected transport to be of type *http.Transport, got %T", client.Transport) + } + + if transport != nil { + t.Fatalf("Expected non-nil transport") + } + + // Check if the minimum TLS version is set to TLS 1.2 + if transport.TLSClientConfig.MinVersion != tls.VersionTLS12 { + t.Errorf("Expected MinVersion to be TLS 1.2, got %v", transport.TLSClientConfig.MinVersion) + } + + // Check if ForceAttemptHTTP2 is set to true + if !transport.ForceAttemptHTTP2 { + t.Errorf("Expected ForceAttemptHTTP2 to be true, got %v", transport.ForceAttemptHTTP2) + } + + // Check if Proxy is set correctly from the environment + req, _ := http.NewRequest("GET", "http://example.com", nil) + proxyURL, err := transport.Proxy(req) + if err != nil { + t.Fatalf("Expected no error from Proxy function, got %v", err) + } + if proxyURL.String() != "http://proxy.example.com" { + t.Errorf("Expected proxy URL to be http://proxy.example.com, got %v", proxyURL) + } +}