Skip to content

Commit

Permalink
test: Skip tests if required plugins are missing (sqlc-dev#2104)
Browse files Browse the repository at this point in the history
* test: Skip tests if required plugins are missing

* Fix failing test
  • Loading branch information
kyleconroy committed Feb 22, 2023
1 parent d460c5d commit c8d493b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/endtoend/endtoend_test.go
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"os"
osexec "os/exec"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -102,6 +103,13 @@ func TestReplay(t *testing.T) {
args := parseExec(t, path)
expected := expectedStderr(t, path)

if args.Process != "" {
_, err := osexec.LookPath(args.Process)
if err != nil {
t.Skipf("executable not found: %s %s", args.Process, err)
}
}

switch args.Command {
case "diff":
err = cmd.Diff(ctx, cmd.Env{ExperimentalFeatures: true}, path, "", &stderr)
Expand Down Expand Up @@ -144,6 +152,9 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) {
if filepath.Base(path) == "sqlc.json" {
return nil
}
if filepath.Base(path) == "exec.json" {
return nil
}
if strings.Contains(path, "/kotlin/build") {
return nil
}
Expand Down Expand Up @@ -199,6 +210,7 @@ func expectedStderr(t *testing.T, dir string) string {

type exec struct {
Command string `json:"command"`
Process string `json:"process"`
}

func parseExec(t *testing.T, dir string) exec {
Expand Down
@@ -0,0 +1,3 @@
{
"process": "sqlc-gen-json"
}

0 comments on commit c8d493b

Please sign in to comment.