Cross-repo sweep — 84 *_test.go files swapped assert.*/require.* for stdlib if-err patterns. Dropped testify direct require from go.mod, go mod tidy updated go.sum. Verification: - `grep -r stretchr/testify --include=*.go .` empty - go.mod has no testify require - `rg "\bassert\.|\brequire\." -g '*.go'` empty Follow-ups out of ticket scope: - pkg/build/ci.go: core.Trim arity mismatch + missing core.Result.Error (regression from prior AX-6 swaps — separate ticket) - pkg/build/signing notarization tests require codesign binary, not available in sandbox (environmental) Closes tasks.lthn.sh/view.php?id=743 Co-authored-by: Codex <noreply@openai.com>
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package sdk
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"dappco.re/go/build/internal/ax"
|
|
)
|
|
|
|
const validOpenAPISpec = `openapi: "3.0.0"
|
|
info:
|
|
title: Test API
|
|
version: "1.0.0"
|
|
paths:
|
|
/health:
|
|
get:
|
|
operationId: getHealth
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
`
|
|
|
|
func TestValidateSpec_Good(t *testing.T) {
|
|
tmpDir := t.TempDir()
|
|
specPath := ax.Join(tmpDir, "openapi.yaml")
|
|
if err := ax.WriteFile(specPath, []byte(validOpenAPISpec), 0o644); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
sdk := New(tmpDir, nil)
|
|
got, err := sdk.ValidateSpec(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if !stdlibAssertEqual(specPath, got) {
|
|
t.Fatalf("want %v, got %v", specPath, got)
|
|
}
|
|
|
|
}
|
|
|
|
func TestValidateSpec_Bad(t *testing.T) {
|
|
tmpDir := t.TempDir()
|
|
specPath := ax.Join(tmpDir, "openapi.yaml")
|
|
if err := ax.WriteFile(specPath, []byte("openapi: 3.0.0\ninfo: [\n"), 0o644); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
sdk := New(tmpDir, nil)
|
|
_, err := sdk.ValidateSpec(context.Background())
|
|
if err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
if !stdlibAssertContains(err.Error(), "failed to load OpenAPI spec") {
|
|
t.Fatalf("expected %v to contain %v", err.Error(), "failed to load OpenAPI spec")
|
|
}
|
|
|
|
}
|
|
|
|
func TestValidateSpec_InvalidDocument_Bad(t *testing.T) {
|
|
tmpDir := t.TempDir()
|
|
specPath := ax.Join(tmpDir, "openapi.yaml")
|
|
if err := ax.WriteFile(specPath, []byte(`openapi: "3.0.0"
|
|
info:
|
|
title: Test API
|
|
paths: {}
|
|
`), 0o644); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
sdk := New(tmpDir, nil)
|
|
_, err := sdk.ValidateSpec(context.Background())
|
|
if err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
if !stdlibAssertContains(err.Error(), "invalid OpenAPI spec") {
|
|
t.Fatalf("expected %v to contain %v", err.Error(), "invalid OpenAPI spec")
|
|
}
|
|
|
|
}
|