Skip to content

Commit

Permalink
Merge pull request #404 from ministryofjustice/feature/add-README-file
Browse files Browse the repository at this point in the history
Added missing README file and updated the unit test name
  • Loading branch information
Khatraf authored Apr 26, 2024
2 parents d38aba3 + 54e5547 commit 1119499
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
46 changes: 46 additions & 0 deletions test/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Terratest Unit Tests

## Initialisation

On first set up of a new repository, run:

```
go mod init github.com/ministryofjustice/<repo-name>
```

Then run:

```
go mod tidy
```

# How to run the tests locally

Run the tests from within the `test` directory using the `testing-test` user credentials.

Get the credentials from https://moj.awsapps.com selecting the testing-test AWS account.

Copy the credentials and export them by pasting them into the terminal from which you will run the tests.

Next go into the testing folder and run the tests.

```
cd test
go mod download
go test -v
```

Upon successful run, you should see an output similar to the below

```
TestLBCreation 2024-04-26T11:30:07+01:00 logger.go:66: Destroy complete! Resources: 17 destroyed.
TestLBCreation 2024-04-26T11:30:07+01:00 logger.go:66:
--- PASS: TestLBCreation (283.85s)
PASS
ok github.com/ministryofjustice/modernisation-platform-terraform-s3-bucket 284.181s
```

## References

1. https://terratest.gruntwork.io/docs/getting-started/quick-start/
2. https://github.com/ministryofjustice/modernisation-platform-terraform-loadbalancer/blob/main/.github/workflows/go-terratest.yml
5 changes: 3 additions & 2 deletions test/load_balancer_test.go → test/module_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"regexp"
"testing"

"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)

func TestLBCreation(t *testing.T) {
Expand Down

0 comments on commit 1119499

Please sign in to comment.