-
Notifications
You must be signed in to change notification settings - Fork 0
test: split e2e tests and add go-zero integration tests #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
e6ec21a
9842941
71a1390
b9ad8e4
5ea17f5
1f022f7
193ec31
737d559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,14 +87,17 @@ jobs: | |
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: stable | ||
| go-version: 1.26 | ||
| cache: true | ||
|
|
||
| - name: Set up goctl | ||
| run: go install github.com/zeromicro/go-zero/tools/goctl@latest | ||
|
spencercjh marked this conversation as resolved.
|
||
|
|
||
|
Comment on lines
+93
to
+95
|
||
| - name: Set up JDK 25 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: "25" | ||
| distribution: "temurin" | ||
|
|
||
| - name: Run E2E tests (${{ matrix.test-type }}) | ||
| - name: Run E2E tests | ||
| run: make test-e2e | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ This directory contains end-to-end tests for the spec-forge CLI tool. | |||||||||||||||
| | `gradle-springboot-openapi-demo` | Gradle | Single module Spring Boot project | | ||||||||||||||||
| | `maven-multi-module-demo` | Maven | Multi-module Spring Boot project | | ||||||||||||||||
| | `gradle-multi-module-demo` | Gradle | Multi-module Spring Boot project | | ||||||||||||||||
| | `gozero-demo` | Go Modules | go-zero framework project | | ||||||||||||||||
|
spencercjh marked this conversation as resolved.
|
||||||||||||||||
|
|
||||||||||||||||
| ## Running Tests | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -21,7 +22,13 @@ go test ./... | |||||||||||||||
|
|
||||||||||||||||
| ### End-to-End Tests | ||||||||||||||||
|
|
||||||||||||||||
| E2E tests require the build tools (Maven/Gradle) to be installed. | ||||||||||||||||
| E2E tests require the following tools to be installed: | ||||||||||||||||
|
|
||||||||||||||||
| - **Java 25** - Required for Spring Boot projects (Maven/Gradle wrappers are included in demo projects) | ||||||||||||||||
| - **goctl** - Required for go-zero projects. Install with: | ||||||||||||||||
| ```bash | ||||||||||||||||
| go install github.com/zeromicro/go-zero/tools/goctl@latest | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+28
to
32
|
||||||||||||||||
| - **goctl** - Required for go-zero projects. Install with: | |
| ```bash | |
| go install github.com/zeromicro/go-zero/tools/goctl@latest | |
| ``` | |
| - **goctl** - Required for go-zero projects. Install with a version pinned to the go-zero dependency used in the `gozero-demo` project, for example: | |
| ```bash | |
| go install github.com/zeromicro/go-zero/tools/goctl@vX.Y.Z |
Note: Using @latest can change goctl behavior over time and may cause end-to-end tests to drift.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //go:build e2e | ||
|
|
||
| package e2e_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/spencercjh/spec-forge/internal/executor" | ||
| ) | ||
|
|
||
| // TestE2E_ErrorHandling_CommandNotFound tests error handling when build tool is not found. | ||
| func TestE2E_ErrorHandling_CommandNotFound(t *testing.T) { | ||
| // Create a temp directory with pom.xml but no maven installed | ||
| tmpDir := t.TempDir() | ||
| pomPath := filepath.Join(tmpDir, "pom.xml") | ||
| if err := os.WriteFile(pomPath, []byte(`<project></project>`), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| ctx := context.Background() | ||
| exec := executor.NewExecutor() | ||
|
|
||
| // Try to run a non-existent command | ||
| _, err := exec.Execute(ctx, &executor.ExecuteOptions{ | ||
| Command: "nonexistent_command_12345", | ||
| Args: []string{}, | ||
| }) | ||
|
|
||
| if err == nil { | ||
| t.Fatal("Expected error for non-existent command") | ||
| } | ||
|
|
||
| // Verify it's a CommandNotFoundError | ||
| if _, ok := errors.AsType[*executor.CommandNotFoundError](err); !ok { | ||
| t.Fatalf("expected CommandNotFoundError, got %T: %v", err, err) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,50 @@ | ||
| module github.com/spencercjh/gozero-demo | ||
|
|
||
| go 1.23.0 | ||
| go 1.26 | ||
|
|
||
| require github.com/zeromicro/go-zero v1.6.0 | ||
| require github.com/zeromicro/go-zero v1.10.0 | ||
|
|
||
| require ( | ||
| github.com/beorn7/perks v1.0.1 // indirect | ||
| github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||
| github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
| github.com/fatih/color v1.15.0 // indirect | ||
| github.com/go-logr/logr v1.2.4 // indirect | ||
| github.com/cenkalti/backoff/v4 v4.3.0 // indirect | ||
| github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
| github.com/fatih/color v1.18.0 // indirect | ||
| github.com/go-logr/logr v1.4.2 // indirect | ||
| github.com/go-logr/stdr v1.2.2 // indirect | ||
| github.com/golang-jwt/jwt/v4 v4.5.2 // indirect | ||
| github.com/golang/protobuf v1.5.3 // indirect | ||
| github.com/google/uuid v1.4.0 // indirect | ||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/grafana/pyroscope-go v1.2.7 // indirect | ||
| github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect | ||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect | ||
| github.com/klauspost/compress v1.18.0 // indirect | ||
| github.com/mattn/go-colorable v0.1.13 // indirect | ||
| github.com/mattn/go-isatty v0.0.20 // indirect | ||
| github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect | ||
| github.com/openzipkin/zipkin-go v0.4.2 // indirect | ||
| github.com/pelletier/go-toml/v2 v2.1.0 // indirect | ||
| github.com/prometheus/client_golang v1.17.0 // indirect | ||
| github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect | ||
| github.com/prometheus/common v0.44.0 // indirect | ||
| github.com/prometheus/procfs v0.11.1 // indirect | ||
| github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
| github.com/openzipkin/zipkin-go v0.4.3 // indirect | ||
| github.com/pelletier/go-toml/v2 v2.2.4 // indirect | ||
| github.com/prometheus/client_golang v1.23.2 // indirect | ||
| github.com/prometheus/client_model v0.6.2 // indirect | ||
| github.com/prometheus/common v0.66.1 // indirect | ||
| github.com/prometheus/procfs v0.16.1 // indirect | ||
| github.com/spaolacci/murmur3 v1.1.0 // indirect | ||
| go.opentelemetry.io/otel v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/zipkin v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/metric v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/sdk v1.19.0 // indirect | ||
| go.opentelemetry.io/otel/trace v1.19.0 // indirect | ||
| go.opentelemetry.io/proto/otlp v1.0.0 // indirect | ||
| go.uber.org/automaxprocs v1.5.3 // indirect | ||
| golang.org/x/net v0.38.0 // indirect | ||
| golang.org/x/sys v0.31.0 // indirect | ||
| golang.org/x/text v0.23.0 // indirect | ||
| google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect | ||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect | ||
| google.golang.org/grpc v1.59.0 // indirect | ||
| google.golang.org/protobuf v1.33.0 // indirect | ||
| go.opentelemetry.io/otel v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/metric v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/sdk v1.24.0 // indirect | ||
| go.opentelemetry.io/otel/trace v1.24.0 // indirect | ||
| go.opentelemetry.io/proto/otlp v1.3.1 // indirect | ||
| go.uber.org/automaxprocs v1.6.0 // indirect | ||
| go.yaml.in/yaml/v2 v2.4.2 // indirect | ||
|
||
| golang.org/x/net v0.43.0 // indirect | ||
| golang.org/x/sys v0.35.0 // indirect | ||
| golang.org/x/text v0.28.0 // indirect | ||
| google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect | ||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect | ||
| google.golang.org/grpc v1.65.0 // indirect | ||
| google.golang.org/protobuf v1.36.11 // indirect | ||
| gopkg.in/yaml.v2 v2.4.0 // indirect | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.