Skip to content

Commit 753f5aa

Browse files
authored
enhance: add simple integration test (#606)
Signed-off-by: Grant Linville <[email protected]>
1 parent 7da2d70 commit 753f5aa

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

.github/workflows/integration.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- docs/**
9+
- tools/**
10+
- README.md
11+
pull_request:
12+
branches:
13+
- main
14+
paths-ignore:
15+
- docs/**
16+
- tools/**
17+
- README.md
18+
19+
jobs:
20+
integration:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-22.04, windows-latest]
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 1
29+
- uses: actions/setup-go@v5
30+
with:
31+
cache: false
32+
go-version: "1.22"
33+
- name: Build
34+
if: matrix.os == 'ubuntu-22.04'
35+
run: make build
36+
- name: build-windows
37+
if: matrix.os == 'windows-latest'
38+
run: make build-exe
39+
- name: Run Integration Tests
40+
run: make integration

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ tidy:
1212
go mod tidy
1313

1414
test:
15-
go test -v ./...
15+
go test -v ./pkg/...
16+
17+
.PHONY: integration
18+
integration:
19+
go test -v ./integration/...
1620

1721
smoke: build
1822
smoke:

integration/cred_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package integration
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestGPTScriptCredential(t *testing.T) {
10+
out, err := GPTScriptExec("cred")
11+
require.NoError(t, err)
12+
require.Contains(t, out, "CREDENTIAL")
13+
}

integration/helpers.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package integration
2+
3+
import (
4+
"os/exec"
5+
"runtime"
6+
)
7+
8+
func GPTScriptExec(args ...string) (string, error) {
9+
cmd := exec.Command("../bin/gptscript", args...)
10+
if runtime.GOOS == "windows" {
11+
cmd = exec.Command("..\\bin\\gptscript.exe", args...)
12+
}
13+
14+
out, err := cmd.CombinedOutput()
15+
return string(out), err
16+
}

0 commit comments

Comments
 (0)