Skip to content

Commit dc4e4f2

Browse files
committed
e2e tests
1 parent edec959 commit dc4e4f2

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

.github/workflows/code-health.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ jobs:
2020
run: make build
2121
- name: Unit Test
2222
run: make test
23+
24+
e2e:
25+
runs-on: ubuntu-latest
26+
permissions: {}
27+
steps:
28+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
29+
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34
30+
with:
31+
go-version-file: 'go.mod'
32+
- name: E2E Test
33+
run: make test-e2e
34+
2335
lint:
2436
runs-on: ubuntu-latest
2537
permissions: {}

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ clean: ## Clean binary folders
2525

2626
.PHONY: test
2727
test: ## Run unit tests
28-
go test ./... -timeout=30s -parallel=4 -race
28+
go test ./internal/... -timeout=30s -parallel=4 -race
2929

3030
.PHONY: test-update
3131
test-update: ## Run unit tests and update the golden files
32-
go test ./... -timeout=30s -parallel=4 -race -update
32+
go test ./internal/... -timeout=30s -parallel=4 -race -update
33+
34+
.PHONY: test-e2e
35+
test-e2e: local ## Run E2E tests (running the plugin binary)
36+
ATLAS_CLI_EXTRA_PLUGIN_DIRECTORY="${PWD}/bin-plugin" go test ./test/... -timeout=30s -parallel=4 -race
3337

3438
.PHONY: local
3539
local: clean build ## Allow to run the plugin locally

test/e2e/cli.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package e2e
2+
3+
import "os/exec"
4+
5+
func RunPlugin(args ...string) (string, error) {
6+
cmd := exec.Command("atlas", args...)
7+
resp, err := cmd.CombinedOutput()
8+
return string(resp), err
9+
}

test/e2e/cli_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package e2e_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/mongodb-labs/atlas-cli-plugin-terraform/test/e2e"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestPlugin(t *testing.T) {
11+
t.Run("Execute TF command", func(t *testing.T) {
12+
resp, err := e2e.RunPlugin("tf")
13+
require.NoError(t, err, resp)
14+
})
15+
}

0 commit comments

Comments
 (0)