Skip to content

Commit ecdbbc2

Browse files
committed
feat: add integration tests
1 parent 5d691f4 commit ecdbbc2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.github/workflows/integration-tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
- name: Build nginx-supportpkg binary
2525
run: |
2626
cd project
27-
go build -o nginx-supportpkg
28-
chmod +x nginx-supportpkg
29-
cp nginx-supportpkg /usr/local/bin/
30-
kubectl nginx-supportpkg
27+
go build -o kubectl-nginx_supportpkg
28+
chmod +x kubectl-nginx_supportpkg
29+
cp kubectl-nginx_supportpkg /usr/local/bin/
30+
kubectl nginx-supportpkg -v
3131
3232
- name: Run tests
3333
run: go test ./tests -v

tests/supportpkg_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import (
77
"testing"
88
)
99

10-
func TestKubectlCommands(t *testing.T) {
11-
// Execute `kubectl` command
12-
cmd := exec.Command("kubectl", "nginx-supportpkg")
10+
func TestKubectlNginxSupportpkgVersion(t *testing.T) {
11+
cmd := exec.Command("kubectl", "nginx-supportpkg", "-v")
1312
var stdout, stderr bytes.Buffer
1413
cmd.Stdout = &stdout
1514
cmd.Stderr = &stderr
16-
_ = cmd.Run()
15+
err := cmd.Run()
16+
if err != nil {
17+
t.Errorf("Failed to run 'kubectl nginx-supportpkg -v': %v", err)
18+
}
1719

18-
// Compare the output with expected result
19-
expectedOutput := "required flag(s)"
20+
expectedOutput := "nginx-supportpkg - version"
2021
actualOutput := stdout.String()
2122
if !strings.Contains(actualOutput, expectedOutput) {
22-
t.Errorf("Expected output should contain \"%s\" but got \"%s\"", expectedOutput, actualOutput)
23+
t.Errorf("Expected output should contain '%s' but got '%s'", expectedOutput, actualOutput)
2324
}
2425
}

0 commit comments

Comments
 (0)