Skip to content

Commit

Permalink
enhance: add simple integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Jul 3, 2024
1 parent d39962e commit cf86376
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: integration

on:
push:
branches:
- main
paths-ignore:
- docs/**
- tools/**
- README.md
pull_request:
branches:
- main
paths-ignore:
- docs/**
- tools/**
- README.md

jobs:
integration:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
with:
cache: false
go-version: "1.22"
- name: Build
if: matrix.os == 'ubuntu-22.04'
run: make build
- name: build-windows
if: matrix.os == 'windows-latest'
run: make build-exe
- name: Run Integration Tests
run: make integration
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ tidy:
go mod tidy

test:
go test -v ./...
go test -v ./pkg/...

.PHONY: integration
integration:
go test -v ./integration/...

smoke: build
smoke:
Expand Down
13 changes: 13 additions & 0 deletions integration/cred_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package integration

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestGPTScriptCredential(t *testing.T) {
out, err := GPTScriptExec("cred")
require.NoError(t, err)
require.Contains(t, out, "CREDENTIAL")
}
16 changes: 16 additions & 0 deletions integration/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package integration

import (
"os/exec"
"runtime"
)

func GPTScriptExec(args ...string) (string, error) {
cmd := exec.Command("../bin/gptscript", args...)
if runtime.GOOS == "windows" {
cmd = exec.Command("..\\bin\\gptscript.exe", args...)
}

out, err := cmd.CombinedOutput()
return string(out), err
}

0 comments on commit cf86376

Please sign in to comment.