From 47ee924c568d5075cf3fef79c338e589348c2fb8 Mon Sep 17 00:00:00 2001 From: Hugo Aguirre Parra Date: Wed, 28 Jan 2026 22:14:24 +0000 Subject: [PATCH 1/2] chore(go): remove testify for test assertions --- go/go.mod | 3 - go/plugins/alloydb/engine_test.go | 29 ++- go/plugins/alloydb/genkit_test.go | 26 ++- go/plugins/alloydb/indexer_test.go | 10 +- go/plugins/alloydb/retriever_test.go | 23 +- go/plugins/compat_oai/generate_live_test.go | 18 +- go/plugins/googlecloud/action_test.go | 109 ++++++--- go/plugins/googlecloud/engagement_test.go | 132 ++++++++--- go/plugins/googlecloud/feature_test.go | 133 ++++++++--- go/plugins/googlecloud/generate_test.go | 143 ++++++++---- go/plugins/googlecloud/googlecloud_test.go | 52 +++-- go/plugins/googlecloud/path_test.go | 97 +++++--- go/plugins/mcp/integration_test.go | 217 +++++++++++++----- go/plugins/postgresql/engine_test.go | 29 ++- go/plugins/postgresql/genkit_test.go | 26 ++- go/plugins/postgresql/indexer_test.go | 10 +- go/plugins/postgresql/retriever_test.go | 23 +- .../vectorsearch/vectorsearch_test.go | 88 ++++--- go/plugins/weaviate/weaviate_test.go | 5 +- go/samples/mcp-git-pr-explainer/go.mod | 2 +- go/samples/mcp-git-pr-explainer/go.sum | 11 +- go/samples/telemetry-test/kitchen_sink/go.mod | 2 +- go/samples/telemetry-test/kitchen_sink/go.sum | 4 +- go/samples/telemetry-test/simple/go.mod | 2 +- go/samples/telemetry-test/simple/go.sum | 4 +- 25 files changed, 852 insertions(+), 346 deletions(-) diff --git a/go/go.mod b/go/go.mod index 2750230ab0..0659353cd1 100644 --- a/go/go.mod +++ b/go/go.mod @@ -29,7 +29,6 @@ require ( github.com/lib/pq v1.10.9 github.com/mark3labs/mcp-go v0.29.0 github.com/pgvector/pgvector-go v0.3.0 - github.com/stretchr/testify v1.10.0 github.com/weaviate/weaviate v1.30.0 github.com/weaviate/weaviate-go-client/v5 v5.1.0 github.com/xeipuuv/gojsonschema v1.2.0 @@ -84,7 +83,6 @@ require ( github.com/buger/jsonparser v1.1.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -117,7 +115,6 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect diff --git a/go/plugins/alloydb/engine_test.go b/go/plugins/alloydb/engine_test.go index 969ee56000..ecea564e4b 100644 --- a/go/plugins/alloydb/engine_test.go +++ b/go/plugins/alloydb/engine_test.go @@ -19,7 +19,6 @@ import ( "testing" "github.com/jackc/pgx/v5/pgxpool" - "github.com/stretchr/testify/assert" ) func TestApplyEngineOptionsConfig(t *testing.T) { @@ -89,10 +88,16 @@ func TestApplyEngineOptionsConfig(t *testing.T) { t.Run(tc.name, func(t *testing.T) { cfg, err := applyEngineOptions(tc.opts) if tc.wantErr { - assert.Error(t, err) + if err == nil { + t.Error("expected error, got nil") + } } else { - assert.NoError(t, err) - assert.Equal(t, tc.wantIpType, cfg.ipType) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if got, want := cfg.ipType, tc.wantIpType; got != want { + t.Errorf("ipType = %v, want %v", got, want) + } } }) } @@ -132,11 +137,19 @@ func TestGetUser(t *testing.T) { ctx := context.Background() user, iamAuth, err := getUser(ctx, tc.cfg) if tc.wantErr { - assert.Error(t, err) + if err == nil { + t.Error("expected error, got nil") + } } else { - assert.NoError(t, err) - assert.Equal(t, tc.wantUser, user) - assert.Equal(t, tc.wantIAMAuth, iamAuth) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if got, want := user, tc.wantUser; got != want { + t.Errorf("user = %q, want %q", got, want) + } + if got, want := iamAuth, tc.wantIAMAuth; got != want { + t.Errorf("iamAuth = %v, want %v", got, want) + } } }) } diff --git a/go/plugins/alloydb/genkit_test.go b/go/plugins/alloydb/genkit_test.go index e2eec4a5db..c94da0ee5d 100644 --- a/go/plugins/alloydb/genkit_test.go +++ b/go/plugins/alloydb/genkit_test.go @@ -24,8 +24,6 @@ import ( "github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/internal/fakeembedder" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) const ( @@ -159,9 +157,15 @@ func TestPostgres(t *testing.T) { if err != nil { t.Fatal(err) } - require.Len(t, resp.Documents, 3) - require.Len(t, resp.Documents[0].Content, 1) - assert.Equal(t, "hello1", resp.Documents[0].Content[0].Text) + if len(resp.Documents) != 3 { + t.Fatalf("expected 3 documents, got %d", len(resp.Documents)) + } + if len(resp.Documents[0].Content) != 1 { + t.Fatalf("expected 1 content part, got %d", len(resp.Documents[0].Content)) + } + if got, want := resp.Documents[0].Content[0].Text, "hello1"; got != want { + t.Errorf("got content %q, want %q", got, want) + } resp, err = retriever.Retrieve(ctx, &ai.RetrieverRequest{ Query: d1, @@ -173,9 +177,15 @@ func TestPostgres(t *testing.T) { t.Fatal(err) } - require.Len(t, resp.Documents, 1) - require.Len(t, resp.Documents[0].Content, 1) - assert.Equal(t, "hello2", resp.Documents[0].Content[0].Text) + if len(resp.Documents) != 1 { + t.Fatalf("expected 1 document, got %d", len(resp.Documents)) + } + if len(resp.Documents[0].Content) != 1 { + t.Fatalf("expected 1 content part, got %d", len(resp.Documents[0].Content)) + } + if got, want := resp.Documents[0].Content[0].Text, "hello2"; got != want { + t.Errorf("got content %q, want %q", got, want) + } } diff --git a/go/plugins/alloydb/indexer_test.go b/go/plugins/alloydb/indexer_test.go index 5cb44c37e4..d5ac3d3d5e 100644 --- a/go/plugins/alloydb/indexer_test.go +++ b/go/plugins/alloydb/indexer_test.go @@ -19,14 +19,14 @@ import ( "testing" "github.com/firebase/genkit/go/ai" - "github.com/stretchr/testify/require" ) func TestIndex_Success_NoDocuments(t *testing.T) { ds := DocStore{} err := ds.Index(context.Background(), nil) - require.NoError(t, err) - + if err != nil { + t.Fatalf("unexpected error: %v", err) + } } func TestIndex_Fail_EmbedReturnError(t *testing.T) { @@ -44,5 +44,7 @@ func TestIndex_Fail_EmbedReturnError(t *testing.T) { }} err := ds.Index(context.Background(), docs) - require.Error(t, err) + if err == nil { + t.Fatal("expected error, got nil") + } } diff --git a/go/plugins/alloydb/retriever_test.go b/go/plugins/alloydb/retriever_test.go index bc9c74a4bf..d102435a47 100644 --- a/go/plugins/alloydb/retriever_test.go +++ b/go/plugins/alloydb/retriever_test.go @@ -16,19 +16,24 @@ package alloydb import ( "context" + "strings" "testing" "github.com/firebase/genkit/go/ai" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRetriever_Fail_WrongTypeOfOption(t *testing.T) { ds := DocStore{} res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{Options: struct{}{}}) - require.Nil(t, res) - require.Error(t, err) - assert.ErrorContains(t, err, "postgres.Retrieve options have type") + if res != nil { + t.Errorf("Retrieve() res = %v, want nil", res) + } + if err == nil { + t.Fatal("Retrieve() expected error, got nil") + } + if want := "postgres.Retrieve options have type"; !strings.Contains(err.Error(), want) { + t.Errorf("Retrieve() error = %q, want it to contain %q", err.Error(), want) + } } func TestRetriever_Fail_EmbedReturnError(t *testing.T) { @@ -36,6 +41,10 @@ func TestRetriever_Fail_EmbedReturnError(t *testing.T) { config: &Config{Embedder: mockEmbedderFail{}}, } res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{}) - require.Nil(t, res) - require.Error(t, err) + if res != nil { + t.Errorf("Retrieve() res = %v, want nil", res) + } + if err == nil { + t.Error("Retrieve() expected error, got nil") + } } diff --git a/go/plugins/compat_oai/generate_live_test.go b/go/plugins/compat_oai/generate_live_test.go index 3e2e340b19..872344fe33 100644 --- a/go/plugins/compat_oai/generate_live_test.go +++ b/go/plugins/compat_oai/generate_live_test.go @@ -26,7 +26,6 @@ import ( "github.com/firebase/genkit/go/plugins/compat_oai" "github.com/openai/openai-go" "github.com/openai/openai-go/option" - "github.com/stretchr/testify/assert" ) const defaultModel = "gpt-4o-mini" @@ -244,14 +243,21 @@ func TestWithConfig(t *testing.T) { result, err := generator.WithMessages(messages).WithConfig(tt.config).Generate(context.Background(), req, nil) if tt.err != nil { - assert.Error(t, err) - assert.Equal(t, tt.err.Error(), err.Error()) + if err == nil { + t.Fatal("expected error, got nil") + } + if got, want := err.Error(), tt.err.Error(); got != want { + t.Errorf("error message = %q, want %q", got, want) + } return } - // validate that the response was successful - assert.NoError(t, err) - assert.NotNil(t, result) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if result == nil { + t.Fatal("expected result, got nil") + } // validate the input request was transformed correctly if tt.validate != nil { diff --git a/go/plugins/googlecloud/action_test.go b/go/plugins/googlecloud/action_test.go index 817a40bc6d..1ac87f656e 100644 --- a/go/plugins/googlecloud/action_test.go +++ b/go/plugins/googlecloud/action_test.go @@ -8,7 +8,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel/attribute" sdktrace "go.opentelemetry.io/otel/sdk/trace" ) @@ -64,14 +63,24 @@ func TestActionTelemetry_PipelineIntegration(t *testing.T) { logOutput := logBuf.String() // Verify action telemetry worked - assert.Contains(t, logOutput, "Input[testFlow > testTool, testFlow]") - assert.Contains(t, logOutput, "Output[testFlow > testTool, testFlow]") - assert.Contains(t, logOutput, "test input data") - assert.Contains(t, logOutput, "test output data") + if !strings.Contains(logOutput, "Input[testFlow > testTool, testFlow]") { + t.Error("logOutput should contain \"Input[testFlow > testTool, testFlow]\"") + } + if !strings.Contains(logOutput, "Output[testFlow > testTool, testFlow]") { + t.Error("logOutput should contain \"Output[testFlow > testTool, testFlow]\"") + } + if !strings.Contains(logOutput, "test input data") { + t.Error("logOutput should contain \"test input data\"") + } + if !strings.Contains(logOutput, "test output data") { + t.Error("logOutput should contain \"test output data\"") + } // Verify the span was exported spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } func TestActionTelemetry_FilteringLogic(t *testing.T) { @@ -191,16 +200,26 @@ func TestActionTelemetry_FilteringLogic(t *testing.T) { // Verify processing behavior if tc.expectProcessing { - assert.Contains(t, logOutput, tc.expectedInputLog, "Expected input log") - assert.Contains(t, logOutput, tc.expectedOutputLog, "Expected output log") + if !strings.Contains(logOutput, tc.expectedInputLog) { + t.Errorf("Expected input log containing %q but got: %q", tc.expectedInputLog, logOutput) + } + if !strings.Contains(logOutput, tc.expectedOutputLog) { + t.Errorf("Expected output log containing %q but got: %q", tc.expectedOutputLog, logOutput) + } } else { - assert.NotContains(t, logOutput, "Input[", "Should not have input logs") - assert.NotContains(t, logOutput, "Output[", "Should not have output logs") + if strings.Contains(logOutput, "Input[") { + t.Error("Should not have input logs") + } + if strings.Contains(logOutput, "Output[") { + t.Error("Should not have output logs") + } } // Verify span was processed regardless spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -350,32 +369,50 @@ func TestActionTelemetry_LoggingBehavior(t *testing.T) { // Verify logging behavior if tc.expectInputLog { - assert.Contains(t, logOutput, tc.expectedInputLog, "Expected input log header") + if !strings.Contains(logOutput, tc.expectedInputLog) { + t.Errorf("Expected input log header %q but got: %q", tc.expectedInputLog, logOutput) + } if tc.expectedInputContent != "" { - assert.Contains(t, logOutput, tc.expectedInputContent, "Expected input content in logs") + if !strings.Contains(logOutput, tc.expectedInputContent) { + t.Errorf("Expected input content %q in logs", tc.expectedInputContent) + } } } else { - assert.NotContains(t, logOutput, "Input[", "Should not have input log") + if strings.Contains(logOutput, "Input[") { + t.Error("Should not have input log") + } if tc.expectedInputContent != "" { - assert.NotContains(t, logOutput, tc.expectedInputContent, "Should not have input content in logs") + if strings.Contains(logOutput, tc.expectedInputContent) { + t.Errorf("Should not have input content %q in logs", tc.expectedInputContent) + } } } if tc.expectOutputLog { - assert.Contains(t, logOutput, tc.expectedOutputLog, "Expected output log header") + if !strings.Contains(logOutput, tc.expectedOutputLog) { + t.Errorf("Expected output log header %q but got: %q", tc.expectedOutputLog, logOutput) + } if tc.expectedOutputContent != "" { - assert.Contains(t, logOutput, tc.expectedOutputContent, "Expected output content in logs") + if !strings.Contains(logOutput, tc.expectedOutputContent) { + t.Errorf("Expected output content %q in logs", tc.expectedOutputContent) + } } } else { - assert.NotContains(t, logOutput, "Output[", "Should not have output log") + if strings.Contains(logOutput, "Output[") { + t.Error("Should not have output log") + } if tc.expectedOutputContent != "" { - assert.NotContains(t, logOutput, tc.expectedOutputContent, "Should not have output content in logs") + if strings.Contains(logOutput, tc.expectedOutputContent) { + t.Errorf("Should not have output content %q in logs", tc.expectedOutputContent) + } } } // Verify span was processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -474,11 +511,15 @@ func TestActionTelemetry_FeatureNameExtraction(t *testing.T) { logOutput := logBuf.String() // Verify feature name extraction worked correctly - assert.Contains(t, logOutput, tc.expectedLog, "Expected log with correct feature name") + if !strings.Contains(logOutput, tc.expectedLog) { + t.Errorf("Expected log with correct feature name %q but got: %q", tc.expectedLog, logOutput) + } // Verify span was processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -585,12 +626,16 @@ func TestActionTelemetry_EdgeCases(t *testing.T) { // Verify logging behavior if tc.expectLogs { - assert.Contains(t, logOutput, tc.expectedLog, "Expected log content") + if !strings.Contains(logOutput, tc.expectedLog) { + t.Errorf("Expected log content %q but got: %q", tc.expectedLog, logOutput) + } } // Verify span was processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -647,16 +692,24 @@ func TestActionTelemetry_InputTruncation(t *testing.T) { logOutput := logBuf.String() // Verify the log header appears - assert.Contains(t, logOutput, "Input[testFlow > myTool, testFlow]", "Expected input log header") + if !strings.Contains(logOutput, "Input[testFlow > myTool, testFlow]") { + t.Error("Expected input log header \"Input[testFlow > myTool, testFlow]\"") + } // Simple verification: check that the original input is not entirely present in logs // If truncation worked, the full 130k character string should not appear in logs - assert.NotContains(t, logOutput, longInput, "Full long input should not appear in logs (should be truncated)") + if strings.Contains(logOutput, longInput) { + t.Error("Full long input should not appear in logs (should be truncated)") + } // Verify that some of the content appears (the beginning should be preserved) - assert.Contains(t, logOutput, "AAAAAAAAAA", "Beginning of input should appear in logs") + if !strings.Contains(logOutput, "AAAAAAAAAA") { + t.Error("Beginning of input should appear in logs") + } // Verify spans were processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } diff --git a/go/plugins/googlecloud/engagement_test.go b/go/plugins/googlecloud/engagement_test.go index a3ca5741ce..4442e264ab 100644 --- a/go/plugins/googlecloud/engagement_test.go +++ b/go/plugins/googlecloud/engagement_test.go @@ -8,9 +8,10 @@ import ( "context" "fmt" "log/slog" + "slices" + "strings" "testing" - "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" sdkmetric "go.opentelemetry.io/otel/sdk/metric" @@ -39,9 +40,15 @@ func setupLogCapture(t *testing.T) *bytes.Buffer { func TestNewEngagementTelemetry(t *testing.T) { engTel := NewEngagementTelemetry() - assert.NotNil(t, engTel) - assert.NotNil(t, engTel.feedbackCounter) - assert.NotNil(t, engTel.acceptanceCounter) + if engTel == nil { + t.Fatal("engTel should not be nil") + } + if engTel.feedbackCounter == nil { + t.Error("feedbackCounter should not be nil") + } + if engTel.acceptanceCounter == nil { + t.Error("acceptanceCounter should not be nil") + } } func TestEngagementTelemetry_extractTraceName(t *testing.T) { @@ -100,7 +107,9 @@ func TestEngagementTelemetry_extractTraceName(t *testing.T) { attribute.String("genkit:path", tc.path), } result := engTel.extractTraceName(attrs) - assert.Equal(t, tc.expected, result) + if result != tc.expected { + t.Errorf("extractTraceName(%q) = %q, want %q", tc.path, result, tc.expected) + } }) } } @@ -134,12 +143,18 @@ func TestEngagementTelemetry_PipelineIntegration(t *testing.T) { logOutput := logBuf.String() // Verify engagement telemetry worked - assert.Contains(t, logOutput, "UserFeedback[myAction,t:action]") - assert.Contains(t, logOutput, "feedbackValue:positive") + if !strings.Contains(logOutput, "UserFeedback[myAction,t:action]") { + t.Error("logOutput should contain \"UserFeedback[myAction,t:action]\"") + } + if !strings.Contains(logOutput, "feedbackValue:positive") { + t.Error("logOutput should contain \"feedbackValue:positive\"") + } // Verify the span was exported with normalized attributes (slash-based) spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } exportedSpan := spans[0] // The exported span should have normalized attributes @@ -150,13 +165,26 @@ func TestEngagementTelemetry_PipelineIntegration(t *testing.T) { } // The span will have normalized attributes (with slashes) for export - assert.Contains(t, attributeKeys, "genkit/metadata/subtype") - assert.Contains(t, attributeKeys, "genkit/path") - assert.Contains(t, attributeKeys, "genkit/metadata/feedbackValue") + if !slices.Contains(attributeKeys, "genkit/metadata/subtype") { + t.Error("attributeKeys should contain \"genkit/metadata/subtype\"") + } + if !slices.Contains(attributeKeys, "genkit/path") { + t.Error("attributeKeys should contain \"genkit/path\"") + } + if !slices.Contains(attributeKeys, "genkit/metadata/feedbackValue") { + t.Error("attributeKeys should contain \"genkit/metadata/feedbackValue\"") + } + // Verify all colon-based attributes were normalized to slash-based - assert.NotContains(t, attributeKeys, "genkit:metadata:subtype") - assert.NotContains(t, attributeKeys, "genkit:path") - assert.NotContains(t, attributeKeys, "genkit:metadata:feedbackValue") + if slices.Contains(attributeKeys, "genkit:metadata:subtype") { + t.Error("attributeKeys should NOT contain \"genkit:metadata:subtype\"") + } + if slices.Contains(attributeKeys, "genkit:path") { + t.Error("attributeKeys should NOT contain \"genkit:path\"") + } + if slices.Contains(attributeKeys, "genkit:metadata:feedbackValue") { + t.Error("attributeKeys should NOT contain \"genkit:metadata:feedbackValue\"") + } } func TestEngagementTelemetry_MetricCapture(t *testing.T) { @@ -257,18 +285,23 @@ func TestEngagementTelemetry_MetricCapture(t *testing.T) { // Wait for span to be processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Collect metrics using the manual reader var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Verify metrics if tc.expectFeedbackMetrics { feedbackMetric := findMetric(&resourceMetrics, "genkit/engagement/feedback") - assert.NotNil(t, feedbackMetric, "Expected feedback metric to be recorded") - if feedbackMetric != nil { + if feedbackMetric == nil { + t.Error("Expected feedback metric to be recorded") + } else { verifyCounterMetric(t, feedbackMetric, map[string]interface{}{ "name": tc.expectedName, "value": tc.expectedFeedbackValue, @@ -280,8 +313,9 @@ func TestEngagementTelemetry_MetricCapture(t *testing.T) { if tc.expectAcceptanceMetrics { acceptanceMetric := findMetric(&resourceMetrics, "genkit/engagement/acceptance") - assert.NotNil(t, acceptanceMetric, "Expected acceptance metric to be recorded") - if acceptanceMetric != nil { + if acceptanceMetric == nil { + t.Error("Expected acceptance metric to be recorded") + } else { verifyCounterMetric(t, acceptanceMetric, map[string]interface{}{ "name": tc.expectedName, "value": tc.expectedAcceptanceValue, @@ -294,8 +328,12 @@ func TestEngagementTelemetry_MetricCapture(t *testing.T) { // Should have no engagement metrics feedbackMetric := findMetric(&resourceMetrics, "genkit/engagement/feedback") acceptanceMetric := findMetric(&resourceMetrics, "genkit/engagement/acceptance") - assert.Nil(t, feedbackMetric, "Should not have feedback metrics") - assert.Nil(t, acceptanceMetric, "Should not have acceptance metrics") + if feedbackMetric != nil { + t.Error("Should not have feedback metrics") + } + if acceptanceMetric != nil { + t.Error("Should not have acceptance metrics") + } } }) } @@ -317,16 +355,23 @@ func findMetric(rm *metricdata.ResourceMetrics, name string) *metricdata.Metrics func verifyCounterMetric(t *testing.T, metric *metricdata.Metrics, expectedAttrs map[string]interface{}) { // Verify it's a counter/sum metric sum, ok := metric.Data.(metricdata.Sum[int64]) - assert.True(t, ok, "Expected metric to be a Sum[int64]") + if !ok { + t.Errorf("Expected metric to be a Sum[int64], got %T", metric.Data) + return + } // Should have exactly one data point for our test - assert.Len(t, sum.DataPoints, 1, "Expected exactly one data point") + if len(sum.DataPoints) != 1 { + t.Fatalf("got %d data points, want 1", len(sum.DataPoints)) + } if len(sum.DataPoints) > 0 { dp := sum.DataPoints[0] // Verify the value (should be 1 for counter) - assert.Equal(t, int64(1), dp.Value, "Expected counter value to be 1") + if got, want := dp.Value, int64(1); got != want { + t.Errorf("Value = %v, want %v", got, want) + } // Verify attributes for expectedKey, expectedValue := range expectedAttrs { @@ -336,18 +381,28 @@ func verifyCounterMetric(t *testing.T, metric *metricdata.Metrics, expectedAttrs found = true switch v := expectedValue.(type) { case string: - assert.Equal(t, v, attr.Value.AsString(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsString(), v; got != want { + t.Errorf("Attribute %s = %q, want %q", expectedKey, got, want) + } case bool: - assert.Equal(t, v, attr.Value.AsBool(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsBool(), v; got != want { + t.Errorf("Attribute %s = %v, want %v", expectedKey, got, want) + } case int64: - assert.Equal(t, v, attr.Value.AsInt64(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsInt64(), v; got != want { + t.Errorf("Attribute %s = %v, want %v", expectedKey, got, want) + } default: - assert.Equal(t, fmt.Sprintf("%v", v), attr.Value.AsString(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsString(), fmt.Sprintf("%v", v); got != want { + t.Errorf("Attribute %s = %q, want %q", expectedKey, got, want) + } } break } } - assert.True(t, found, "Expected attribute %s not found", expectedKey) + if !found { + t.Errorf("Expected attribute %s not found", expectedKey) + } } } } @@ -443,16 +498,23 @@ func TestEngagementTelemetry_ComprehensiveScenarios(t *testing.T) { // Verify spans were processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Check logging behavior if tc.expectLog { - assert.Contains(t, logOutput, tc.expectedText, - "Expected log containing %q but got: %q", tc.expectedText, logOutput) + if !strings.Contains(logOutput, tc.expectedText) { + t.Errorf("Expected log containing %q but got: %q", tc.expectedText, logOutput) + } } else { // Should not contain engagement logs - assert.NotContains(t, logOutput, "UserFeedback[", "Unexpected UserFeedback log") - assert.NotContains(t, logOutput, "UserAcceptance[", "Unexpected UserAcceptance log") + if strings.Contains(logOutput, "UserFeedback[") { + t.Error("Unexpected UserFeedback log") + } + if strings.Contains(logOutput, "UserAcceptance[") { + t.Error("Unexpected UserAcceptance log") + } } }) } diff --git a/go/plugins/googlecloud/feature_test.go b/go/plugins/googlecloud/feature_test.go index b7f85d7ae1..8d2ac8d5b5 100644 --- a/go/plugins/googlecloud/feature_test.go +++ b/go/plugins/googlecloud/feature_test.go @@ -6,10 +6,10 @@ package googlecloud import ( "context" "fmt" + "strings" "testing" "time" - "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" sdkmetric "go.opentelemetry.io/otel/sdk/metric" @@ -42,7 +42,9 @@ func TestFeatureTelemetry_PipelineIntegration(t *testing.T) { // Verify the span was exported spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } func TestFeatureTelemetry_MetricCapture(t *testing.T) { @@ -170,18 +172,23 @@ func TestFeatureTelemetry_MetricCapture(t *testing.T) { // Wait for span to be processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Collect metrics using the manual reader var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Verify counter metrics if tc.expectCounterMetrics { counterMetric := findMetric(&resourceMetrics, "genkit/feature/requests") - assert.NotNil(t, counterMetric, "Expected counter metric to be recorded") - if counterMetric != nil { + if counterMetric == nil { + t.Error("Expected counter metric to be recorded") + } else { expectedAttrs := map[string]interface{}{ "name": tc.expectedName, "status": tc.expectedStatus, @@ -197,8 +204,9 @@ func TestFeatureTelemetry_MetricCapture(t *testing.T) { // Verify histogram metrics if tc.expectHistogramMetrics { histogramMetric := findMetric(&resourceMetrics, "genkit/feature/latency") - assert.NotNil(t, histogramMetric, "Expected histogram metric to be recorded") - if histogramMetric != nil { + if histogramMetric == nil { + t.Error("Expected histogram metric to be recorded") + } else { expectedAttrs := map[string]interface{}{ "name": tc.expectedName, "status": tc.expectedStatus, @@ -215,8 +223,12 @@ func TestFeatureTelemetry_MetricCapture(t *testing.T) { // Should have no feature metrics counterMetric := findMetric(&resourceMetrics, "genkit/feature/requests") histogramMetric := findMetric(&resourceMetrics, "genkit/feature/latency") - assert.Nil(t, counterMetric, "Should not have counter metrics") - assert.Nil(t, histogramMetric, "Should not have histogram metrics") + if counterMetric != nil { + t.Error("Should not have counter metrics") + } + if histogramMetric != nil { + t.Error("Should not have histogram metrics") + } } }) } @@ -302,7 +314,9 @@ func TestFeatureTelemetry_ComprehensiveScenarios(t *testing.T) { // Verify spans were processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -359,42 +373,63 @@ func TestFeatureTelemetry_InputOutputLogging(t *testing.T) { logOutput := logBuf.String() // Verify input/output logs are present - we explicitly enabled logInputOutput=true - assert.Contains(t, logOutput, "Input[", "Expected input log") - assert.Contains(t, logOutput, "Output[", "Expected output log") - assert.Contains(t, logOutput, "testFeature", "Expected feature name in logs") + if !strings.Contains(logOutput, "Input[") { + t.Error("Expected input log") + } + if !strings.Contains(logOutput, "Output[") { + t.Error("Expected output log") + } + if !strings.Contains(logOutput, "testFeature") { + t.Error("Expected feature name in logs") + } // Verify spans were processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } // Helper function for histogram metric verification (reuses counter verification pattern) func verifyHistogramMetric(t *testing.T, metric *metricdata.Metrics, expectedAttrs map[string]interface{}) { // Verify it's a histogram metric histogram, ok := metric.Data.(metricdata.Histogram[float64]) - assert.True(t, ok, "Expected metric to be a Histogram[float64]") + if !ok { + t.Errorf("Expected metric to be a Histogram[float64], got %T", metric.Data) + return + } // Should have exactly one data point for our test - assert.Len(t, histogram.DataPoints, 1, "Expected exactly one data point") + if len(histogram.DataPoints) != 1 { + t.Fatalf("got %d data points, want 1", len(histogram.DataPoints)) + } if len(histogram.DataPoints) > 0 { dp := histogram.DataPoints[0] // Verify the count (should be 1 for our test) - assert.Equal(t, uint64(1), dp.Count, "Expected histogram count to be 1") + if got, want := dp.Count, uint64(1); got != want { + t.Errorf("Count = %v, want %v", got, want) + } // Verify the latency value is reasonable for a test span - assert.Greater(t, dp.Sum, float64(0), "Expected histogram sum to be positive") + if dp.Sum <= 0 { + t.Errorf("Sum = %v, want > 0", dp.Sum) + } // Verify we have bucket counts (histogram should have buckets) - assert.NotEmpty(t, dp.BucketCounts, "Expected histogram to have bucket counts") + if len(dp.BucketCounts) == 0 { + t.Error("Expected histogram to have bucket counts") + } // Verify the sum of bucket counts equals the total count var totalBucketCount uint64 for _, bucketCount := range dp.BucketCounts { totalBucketCount += bucketCount } - assert.Equal(t, dp.Count, totalBucketCount, "Sum of bucket counts should equal total count") + if totalBucketCount != dp.Count { + t.Errorf("Sum of bucket counts = %v, want %v", totalBucketCount, dp.Count) + } // Verify attributes (reuse same pattern as counter verification) for expectedKey, expectedValue := range expectedAttrs { @@ -404,18 +439,28 @@ func verifyHistogramMetric(t *testing.T, metric *metricdata.Metrics, expectedAtt found = true switch v := expectedValue.(type) { case string: - assert.Equal(t, v, attr.Value.AsString(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsString(), v; got != want { + t.Errorf("Attribute %s = %q, want %q", expectedKey, got, want) + } case bool: - assert.Equal(t, v, attr.Value.AsBool(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsBool(), v; got != want { + t.Errorf("Attribute %s = %v, want %v", expectedKey, got, want) + } case int64: - assert.Equal(t, v, attr.Value.AsInt64(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsInt64(), v; got != want { + t.Errorf("Attribute %s = %v, want %v", expectedKey, got, want) + } default: - assert.Equal(t, fmt.Sprintf("%v", v), attr.Value.AsString(), "Attribute %s mismatch", expectedKey) + if got, want := attr.Value.AsString(), fmt.Sprintf("%v", v); got != want { + t.Errorf("Attribute %s = %q, want %q", expectedKey, got, want) + } } break } } - assert.True(t, found, "Expected attribute %s not found", expectedKey) + if !found { + t.Errorf("Expected attribute %s not found", expectedKey) + } } } } @@ -450,27 +495,43 @@ func TestFeatureTelemetry_LatencyVerification(t *testing.T) { // Collect metrics var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Verify latency histogram histogramMetric := findMetric(&resourceMetrics, "genkit/feature/latency") - assert.NotNil(t, histogramMetric, "Expected latency histogram metric") + if histogramMetric == nil { + t.Fatal("Expected latency histogram metric") + } if histogramMetric != nil { histogram, ok := histogramMetric.Data.(metricdata.Histogram[float64]) - assert.True(t, ok, "Expected histogram type") + if !ok { + t.Errorf("Expected histogram type, got %T", histogramMetric.Data) + } if len(histogram.DataPoints) > 0 { dp := histogram.DataPoints[0] // More specific latency assertions - assert.Equal(t, uint64(1), dp.Count, "Should have one measurement") - assert.GreaterOrEqual(t, dp.Sum, 1.0, "Should have at least 1ms latency due to sleep") - assert.Less(t, dp.Sum, 100.0, "Should be less than 100ms for test span") + if got, want := dp.Count, uint64(1); got != want { + t.Errorf("Count = %v, want %v", got, want) + } + if dp.Sum < 1.0 { + t.Errorf("Sum = %v, want >= 1.0", dp.Sum) + } + if dp.Sum >= 100.0 { + t.Errorf("Sum = %v, want < 100.0", dp.Sum) + } // Verify histogram has reasonable structure - assert.NotEmpty(t, dp.BucketCounts, "Should have histogram buckets") - assert.NotEmpty(t, dp.Bounds, "Should have bucket boundaries") + if len(dp.BucketCounts) == 0 { + t.Error("Should have histogram buckets") + } + if len(dp.Bounds) == 0 { + t.Error("Should have bucket boundaries") + } // At least one bucket should contain our measurement hasNonZeroBucket := false @@ -480,7 +541,9 @@ func TestFeatureTelemetry_LatencyVerification(t *testing.T) { break } } - assert.True(t, hasNonZeroBucket, "At least one bucket should contain the measurement") + if !hasNonZeroBucket { + t.Error("At least one bucket should contain the measurement") + } } } } diff --git a/go/plugins/googlecloud/generate_test.go b/go/plugins/googlecloud/generate_test.go index 694365f153..9f2efdf17d 100644 --- a/go/plugins/googlecloud/generate_test.go +++ b/go/plugins/googlecloud/generate_test.go @@ -7,7 +7,6 @@ import ( "context" "testing" - "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -45,7 +44,9 @@ func TestGenerateTelemetry_PipelineIntegration(t *testing.T) { // Verify the span was exported spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } func TestGenerateTelemetry_MetricCapture(t *testing.T) { @@ -194,18 +195,23 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Wait for span to be processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Collect metrics using the manual reader var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } if tc.expectMetrics { // Verify request counter requestMetric := findMetric(&resourceMetrics, "genkit/ai/generate/requests") - assert.NotNil(t, requestMetric, "Expected generate/requests metric") - if requestMetric != nil { + if requestMetric == nil { + t.Error("Expected generate/requests metric") + } else { verifyCounterMetric(t, requestMetric, map[string]interface{}{ "modelName": tc.attrs["genkit:name"], "status": tc.expectedStatus, @@ -216,16 +222,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify character metrics if we have usage data if tc.expectedInputChars > 0 { inputCharMetric := findMetric(&resourceMetrics, "genkit/ai/generate/input/characters") - assert.NotNil(t, inputCharMetric, "Expected input/characters metric") - if inputCharMetric != nil { + if inputCharMetric == nil { + t.Error("Expected input/characters metric") + } else { verifyCounterMetricValue(t, inputCharMetric, tc.expectedInputChars) } } if tc.expectedOutputChars > 0 { outputCharMetric := findMetric(&resourceMetrics, "genkit/ai/generate/output/characters") - assert.NotNil(t, outputCharMetric, "Expected output/characters metric") - if outputCharMetric != nil { + if outputCharMetric == nil { + t.Error("Expected output/characters metric") + } else { verifyCounterMetricValue(t, outputCharMetric, tc.expectedOutputChars) } } @@ -233,16 +241,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify token metrics if tc.expectedInputTokens > 0 { inputTokenMetric := findMetric(&resourceMetrics, "genkit/ai/generate/input/tokens") - assert.NotNil(t, inputTokenMetric, "Expected input/tokens metric") - if inputTokenMetric != nil { + if inputTokenMetric == nil { + t.Error("Expected input/tokens metric") + } else { verifyCounterMetricValue(t, inputTokenMetric, tc.expectedInputTokens) } } if tc.expectedOutputTokens > 0 { outputTokenMetric := findMetric(&resourceMetrics, "genkit/ai/generate/output/tokens") - assert.NotNil(t, outputTokenMetric, "Expected output/tokens metric") - if outputTokenMetric != nil { + if outputTokenMetric == nil { + t.Error("Expected output/tokens metric") + } else { verifyCounterMetricValue(t, outputTokenMetric, tc.expectedOutputTokens) } } @@ -250,16 +260,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify image metrics if tc.expectedInputImages > 0 { inputImageMetric := findMetric(&resourceMetrics, "genkit/ai/generate/input/images") - assert.NotNil(t, inputImageMetric, "Expected input/images metric") - if inputImageMetric != nil { + if inputImageMetric == nil { + t.Error("Expected input/images metric") + } else { verifyCounterMetricValue(t, inputImageMetric, tc.expectedInputImages) } } if tc.expectedOutputImages > 0 { outputImageMetric := findMetric(&resourceMetrics, "genkit/ai/generate/output/images") - assert.NotNil(t, outputImageMetric, "Expected output/images metric") - if outputImageMetric != nil { + if outputImageMetric == nil { + t.Error("Expected output/images metric") + } else { verifyCounterMetricValue(t, outputImageMetric, tc.expectedOutputImages) } } @@ -267,16 +279,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify video metrics if tc.expectedInputVideos > 0 { inputVideoMetric := findMetric(&resourceMetrics, "genkit/ai/generate/input/videos") - assert.NotNil(t, inputVideoMetric, "Expected input/videos metric") - if inputVideoMetric != nil { + if inputVideoMetric == nil { + t.Error("Expected input/videos metric") + } else { verifyCounterMetricValue(t, inputVideoMetric, tc.expectedInputVideos) } } if tc.expectedOutputVideos > 0 { outputVideoMetric := findMetric(&resourceMetrics, "genkit/ai/generate/output/videos") - assert.NotNil(t, outputVideoMetric, "Expected output/videos metric") - if outputVideoMetric != nil { + if outputVideoMetric == nil { + t.Error("Expected output/videos metric") + } else { verifyCounterMetricValue(t, outputVideoMetric, tc.expectedOutputVideos) } } @@ -284,16 +298,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify audio metrics if tc.expectedInputAudio > 0 { inputAudioMetric := findMetric(&resourceMetrics, "genkit/ai/generate/input/audio") - assert.NotNil(t, inputAudioMetric, "Expected input/audio metric") - if inputAudioMetric != nil { + if inputAudioMetric == nil { + t.Error("Expected input/audio metric") + } else { verifyCounterMetricValue(t, inputAudioMetric, tc.expectedInputAudio) } } if tc.expectedOutputAudio > 0 { outputAudioMetric := findMetric(&resourceMetrics, "genkit/ai/generate/output/audio") - assert.NotNil(t, outputAudioMetric, "Expected output/audio metric") - if outputAudioMetric != nil { + if outputAudioMetric == nil { + t.Error("Expected output/audio metric") + } else { verifyCounterMetricValue(t, outputAudioMetric, tc.expectedOutputAudio) } } @@ -301,15 +317,18 @@ func TestGenerateTelemetry_MetricCapture(t *testing.T) { // Verify latency histogram if tc.expectedLatency > 0 { latencyMetric := findMetric(&resourceMetrics, "genkit/ai/generate/latency") - assert.NotNil(t, latencyMetric, "Expected latency metric") - if latencyMetric != nil { + if latencyMetric == nil { + t.Error("Expected latency metric") + } else { verifyHistogramMetricValue(t, latencyMetric, tc.expectedLatency) } } } else { // Should have no generate metrics requestMetric := findMetric(&resourceMetrics, "genkit/ai/generate/requests") - assert.Nil(t, requestMetric, "Should not have generate metrics for non-model spans") + if requestMetric != nil { + t.Error("Should not have generate metrics for non-model spans") + } } }) } @@ -374,7 +393,9 @@ func TestGenerateTelemetry_FilteringLogic(t *testing.T) { // Verify span was processed by pipeline spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -450,16 +471,25 @@ func TestGenerateTelemetry_JSONParsingEdgeCases(t *testing.T) { // Function that should not panic testFunc := func() { + defer func() { + if r := recover(); r != nil { + if !tc.expectPanic { + t.Errorf("Should handle malformed JSON gracefully, but got panic: %v", r) + } + } else { + if tc.expectPanic { + t.Error("Expected panic for malformed data") + } + } + }() span.End() spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } - if tc.expectPanic { - assert.Panics(t, testFunc, "Expected panic for malformed data") - } else { - assert.NotPanics(t, testFunc, "Should handle malformed JSON gracefully") - } + testFunc() }) } } @@ -527,7 +557,9 @@ func TestGenerateTelemetry_FeatureNameExtraction(t *testing.T) { // Verify span was processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } }) } } @@ -536,33 +568,50 @@ func TestGenerateTelemetry_FeatureNameExtraction(t *testing.T) { func verifyCounterMetricValue(t *testing.T, metric *metricdata.Metrics, expectedValue int64) { sum, ok := metric.Data.(metricdata.Sum[int64]) - assert.True(t, ok, "Expected metric to be a Sum[int64]") + if !ok { + t.Errorf("Expected metric to be a Sum[int64], got %T", metric.Data) + return + } - assert.Len(t, sum.DataPoints, 1, "Expected exactly one data point") - if len(sum.DataPoints) > 0 { - assert.Equal(t, expectedValue, sum.DataPoints[0].Value, "Metric value mismatch") + if len(sum.DataPoints) != 1 { + t.Fatalf("got %d data points, want 1", len(sum.DataPoints)) + } + if got, want := sum.DataPoints[0].Value, expectedValue; got != want { + t.Errorf("Metric value = %v, want %v", got, want) } } func verifyHistogramMetricValue(t *testing.T, metric *metricdata.Metrics, expectedValue float64) { // Try Int64Histogram first (for latency metrics) if hist, ok := metric.Data.(metricdata.Histogram[int64]); ok { - assert.Len(t, hist.DataPoints, 1, "Expected exactly one data point") + if len(hist.DataPoints) != 1 { + t.Fatalf("got %d data points, want 1", len(hist.DataPoints)) + } if len(hist.DataPoints) > 0 { dp := hist.DataPoints[0] - assert.Equal(t, int64(expectedValue), dp.Sum, "Histogram sum mismatch") - assert.Equal(t, uint64(1), dp.Count, "Histogram count should be 1") + if got, want := dp.Sum, int64(expectedValue); got != want { + t.Errorf("Histogram sum = %v, want %v", got, want) + } + if got, want := dp.Count, uint64(1); got != want { + t.Errorf("Histogram count = %v, want %v", got, want) + } } return } // Try Float64Histogram as fallback if hist, ok := metric.Data.(metricdata.Histogram[float64]); ok { - assert.Len(t, hist.DataPoints, 1, "Expected exactly one data point") + if len(hist.DataPoints) != 1 { + t.Fatalf("got %d data points, want 1", len(hist.DataPoints)) + } if len(hist.DataPoints) > 0 { dp := hist.DataPoints[0] - assert.Equal(t, expectedValue, dp.Sum, "Histogram sum mismatch") - assert.Equal(t, uint64(1), dp.Count, "Histogram count should be 1") + if got, want := dp.Sum, expectedValue; got != want { + t.Errorf("Histogram sum = %v, want %v", got, want) + } + if got, want := dp.Count, uint64(1); got != want { + t.Errorf("Histogram count = %v, want %v", got, want) + } } return } diff --git a/go/plugins/googlecloud/googlecloud_test.go b/go/plugins/googlecloud/googlecloud_test.go index bfd1beaea2..498dcc2c9a 100644 --- a/go/plugins/googlecloud/googlecloud_test.go +++ b/go/plugins/googlecloud/googlecloud_test.go @@ -9,8 +9,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" sdktrace "go.opentelemetry.io/otel/sdk/trace" @@ -184,13 +182,17 @@ func (f *testFixture) waitAndGetSpans() []sdktrace.ReadOnlySpan { func (f *testFixture) assertSpanCount(t *testing.T, expected int) []sdktrace.ReadOnlySpan { spans := f.waitAndGetSpans() - assert.Len(t, spans, expected) + if len(spans) != expected { + t.Errorf("got %d spans, want %d", len(spans), expected) + } return spans } func (f *testFixture) assertSpanExists(t *testing.T, name string) sdktrace.ReadOnlySpan { span := f.mockExporter.GetSpanByName(name) - require.NotNil(t, span, "span '%s' should exist", name) + if span == nil { + t.Fatalf("span %q should exist", name) + } return span } @@ -205,8 +207,14 @@ func getAttrMap(span sdktrace.ReadOnlySpan) map[string]string { func assertAttr(t *testing.T, span sdktrace.ReadOnlySpan, key, expected string) { attrMap := getAttrMap(span) - assert.Contains(t, attrMap, key) - assert.Equal(t, expected, attrMap[key]) + got, ok := attrMap[key] + if !ok { + t.Errorf("attribute %q not found", key) + return + } + if got != expected { + t.Errorf("attribute %q = %q, want %q", key, got, expected) + } } // Tests @@ -220,10 +228,18 @@ func TestNewAdjustingTraceExporter(t *testing.T) { projectId: "test-project", } - assert.NotNil(t, adjuster) - assert.Equal(t, mockExporter, adjuster.exporter) - assert.Equal(t, "test-project", adjuster.projectId) - assert.False(t, adjuster.logInputAndOutput) + if adjuster == nil { + t.Fatal("adjuster should not be nil") + } + if got, want := adjuster.exporter, mockExporter; got != want { + t.Errorf("exporter = %v, want %v", got, want) + } + if got, want := adjuster.projectId, "test-project"; got != want { + t.Errorf("projectId = %q, want %q", got, want) + } + if adjuster.logInputAndOutput { + t.Error("logInputAndOutput should be false") + } } func TestAdjustingTraceExporter_ExportSpansWithRealTracer(t *testing.T) { @@ -258,7 +274,9 @@ func TestAdjustingTraceExporter_FailedSpan(t *testing.T) { // Verify spans := f.assertSpanCount(t, 1) - assert.Equal(t, codes.Error, spans[0].Status().Code) + if got, want := spans[0].Status().Code, codes.Error; got != want { + t.Errorf("status code = %v, want %v", got, want) + } } func TestAdjustingTraceExporter_NormalizeLabels(t *testing.T) { @@ -290,8 +308,12 @@ func TestAdjustingTraceExporter_Shutdown(t *testing.T) { } err := adjuster.Shutdown(context.Background()) - require.NoError(t, err) - assert.True(t, mockExporter.shutdownCalled) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if !mockExporter.shutdownCalled { + t.Error("shutdownCalled should be true") + } } func TestCompleteSpanProcessingPipeline(t *testing.T) { @@ -325,5 +347,7 @@ func TestCompleteSpanProcessingPipeline(t *testing.T) { assertAttr(t, generateSpan, "test/colon", "should-be-normalized") assertAttr(t, generateSpan, "genkit/model", "gemini-pro") assertAttr(t, featureSpan, "genkit/type", "feature") - assert.Equal(t, codes.Error, failedSpan.Status().Code) + if got, want := failedSpan.Status().Code, codes.Error; got != want { + t.Errorf("status code = %v, want %v", got, want) + } } diff --git a/go/plugins/googlecloud/path_test.go b/go/plugins/googlecloud/path_test.go index 29f57e5d2d..3bf179907c 100644 --- a/go/plugins/googlecloud/path_test.go +++ b/go/plugins/googlecloud/path_test.go @@ -5,10 +5,10 @@ package googlecloud import ( "context" + "strings" "testing" "time" - "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -19,9 +19,15 @@ import ( func TestNewPathTelemetry(t *testing.T) { pathTel := NewPathTelemetry() - assert.NotNil(t, pathTel) - assert.NotNil(t, pathTel.pathCounter) - assert.NotNil(t, pathTel.pathLatencies) + if pathTel == nil { + t.Fatal("pathTel should not be nil") + } + if pathTel.pathCounter == nil { + t.Error("pathCounter should not be nil") + } + if pathTel.pathLatencies == nil { + t.Error("pathLatencies should not be nil") + } } // TestPathTelemetry_PipelineIntegration verifies that path telemetry @@ -56,11 +62,15 @@ func TestPathTelemetry_PipelineIntegration(t *testing.T) { logOutput := logBuf.String() // Verify path telemetry processed the failing span - assert.Contains(t, logOutput, "Error[") + if !strings.Contains(logOutput, "Error[") { + t.Error("logOutput should contain \"Error[\"") + } // Verify the span was exported spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } } func TestPathTelemetry_MetricCapture(t *testing.T) { @@ -171,18 +181,23 @@ func TestPathTelemetry_MetricCapture(t *testing.T) { // Wait for span to be processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Collect metrics using the manual reader var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Verify counter metrics if tc.expectCounterMetrics { counterMetric := findMetric(&resourceMetrics, "genkit/feature/path/requests") - assert.NotNil(t, counterMetric, "Expected counter metric to be recorded") - if counterMetric != nil { + if counterMetric == nil { + t.Error("Expected counter metric to be recorded") + } else { expectedAttrs := map[string]interface{}{ "featureName": tc.expectedFeatureName, "status": "failure", @@ -198,8 +213,9 @@ func TestPathTelemetry_MetricCapture(t *testing.T) { // Verify histogram metrics if tc.expectHistogramMetrics { histogramMetric := findMetric(&resourceMetrics, "genkit/feature/path/latency") - assert.NotNil(t, histogramMetric, "Expected histogram metric to be recorded") - if histogramMetric != nil { + if histogramMetric == nil { + t.Error("Expected histogram metric to be recorded") + } else { expectedAttrs := map[string]interface{}{ "featureName": tc.expectedFeatureName, "status": "failure", @@ -216,8 +232,12 @@ func TestPathTelemetry_MetricCapture(t *testing.T) { // Should have no path metrics counterMetric := findMetric(&resourceMetrics, "genkit/feature/path/requests") histogramMetric := findMetric(&resourceMetrics, "genkit/feature/path/latency") - assert.Nil(t, counterMetric, "Should not have counter metrics") - assert.Nil(t, histogramMetric, "Should not have histogram metrics") + if counterMetric != nil { + t.Error("Should not have counter metrics") + } + if histogramMetric != nil { + t.Error("Should not have histogram metrics") + } } }) } @@ -321,14 +341,19 @@ func TestPathTelemetry_ComprehensiveScenarios(t *testing.T) { // Verify spans were processed spans := f.waitAndGetSpans() - assert.Len(t, spans, 1) + if len(spans) != 1 { + t.Errorf("got %d spans, want 1", len(spans)) + } // Check logging behavior if tc.expectLog { - assert.Contains(t, logOutput, tc.expectedText, - "Expected log containing %q but got: %q", tc.expectedText, logOutput) + if !strings.Contains(logOutput, tc.expectedText) { + t.Errorf("Expected log containing %q but got: %q", tc.expectedText, logOutput) + } } else { - assert.NotContains(t, logOutput, "Error[", "Should not log errors for non-qualifying spans") + if strings.Contains(logOutput, "Error[") { + t.Error("Should not log errors for non-qualifying spans") + } } }) } @@ -367,27 +392,43 @@ func TestPathTelemetry_LatencyVerification(t *testing.T) { // Collect metrics var resourceMetrics metricdata.ResourceMetrics err := reader.Collect(ctx, &resourceMetrics) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Verify latency histogram histogramMetric := findMetric(&resourceMetrics, "genkit/feature/path/latency") - assert.NotNil(t, histogramMetric, "Expected latency histogram metric") + if histogramMetric == nil { + t.Fatal("Expected latency histogram metric") + } if histogramMetric != nil { histogram, ok := histogramMetric.Data.(metricdata.Histogram[float64]) - assert.True(t, ok, "Expected histogram type") + if !ok { + t.Errorf("Expected histogram type, got %T", histogramMetric.Data) + } if len(histogram.DataPoints) > 0 { dp := histogram.DataPoints[0] // More specific latency assertions - assert.Equal(t, uint64(1), dp.Count, "Should have one measurement") - assert.GreaterOrEqual(t, dp.Sum, 2.0, "Should have at least 2ms latency due to sleep") - assert.Less(t, dp.Sum, 100.0, "Should be less than 100ms for test span") + if got, want := dp.Count, uint64(1); got != want { + t.Errorf("Count = %v, want %v", got, want) + } + if dp.Sum < 2.0 { + t.Errorf("Sum = %v, want >= 2.0", dp.Sum) + } + if dp.Sum >= 100.0 { + t.Errorf("Sum = %v, want < 100.0", dp.Sum) + } // Verify histogram has reasonable structure - assert.NotEmpty(t, dp.BucketCounts, "Should have histogram buckets") - assert.NotEmpty(t, dp.Bounds, "Should have bucket boundaries") + if len(dp.BucketCounts) == 0 { + t.Error("Should have histogram buckets") + } + if len(dp.Bounds) == 0 { + t.Error("Should have bucket boundaries") + } // At least one bucket should contain our measurement hasNonZeroBucket := false @@ -397,7 +438,9 @@ func TestPathTelemetry_LatencyVerification(t *testing.T) { break } } - assert.True(t, hasNonZeroBucket, "At least one bucket should contain the measurement") + if !hasNonZeroBucket { + t.Error("At least one bucket should contain the measurement") + } } } } diff --git a/go/plugins/mcp/integration_test.go b/go/plugins/mcp/integration_test.go index fded91f050..5aff449192 100644 --- a/go/plugins/mcp/integration_test.go +++ b/go/plugins/mcp/integration_test.go @@ -24,7 +24,6 @@ import ( "github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" - "github.com/stretchr/testify/assert" ) // TestMCPConnectionAndTranslation tests the full integration between @@ -45,7 +44,9 @@ func TestMCPConnectionAndTranslation(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/basic_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // SETUP: Genkit client g := genkit.Init(ctx) @@ -53,7 +54,9 @@ func TestMCPConnectionAndTranslation(t *testing.T) { host, err := NewMCPHost(g, MCPHostOptions{ Name: "test-host", }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // TEST: Connect to MCP server err = host.Connect(ctx, g, "test-server", MCPClientOptions{ @@ -64,14 +67,20 @@ func TestMCPConnectionAndTranslation(t *testing.T) { }) // ASSERT 1: Connection succeeds - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // TEST: Discover resources resources, err := host.GetActiveResources(ctx) // ASSERT 2: Resources discovered - assert.NoError(t, err) - assert.Greater(t, len(resources), 0, "Should discover at least 1 resource from test server") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(resources) == 0 { + t.Error("Should discover at least 1 resource from test server") + } // ASSERT 3: MCP template became Genkit resource found := false @@ -82,7 +91,9 @@ func TestMCPConnectionAndTranslation(t *testing.T) { break } } - assert.True(t, found, "Template 'file://test/{filename}' should match 'file://test/README.md'") + if !found { + t.Errorf("Template 'file://test/{filename}' should match 'file://test/README.md'") + } } // TestMCPAIIntegration tests that MCP resources work with AI generation. @@ -101,7 +112,9 @@ func TestMCPAIIntegration(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/policy_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // SETUP: Genkit with MCP and mock model g := genkit.Init(ctx) @@ -125,18 +138,26 @@ func TestMCPAIIntegration(t *testing.T) { }) host, err := NewMCPHost(g, MCPHostOptions{Name: "test-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "policy-server", MCPClientOptions{ Name: "policy-server", Stdio: &StdioConfig{Command: serverBinary}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Get resources from MCP (like mcp-client sample) hostResources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) - assert.Greater(t, len(hostResources), 0, "Should have MCP resources") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(hostResources) == 0 { + t.Error("Should have MCP resources") + } // TEST: AI generation with MCP resources (like resource_test.go) resp, err := genkit.Generate(ctx, g, @@ -150,15 +171,23 @@ func TestMCPAIIntegration(t *testing.T) { ) // ASSERT: Generation succeeds and includes resource content - assert.NoError(t, err) - assert.NotNil(t, resp) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if resp == nil { + t.Fatal("expected response, got nil") + } result := resp.Text() t.Logf("AI response: %s", result) // Verify resource content was resolved and included - assert.Contains(t, result, "VACATION_POLICY", "Should include resource content") - assert.Contains(t, result, "20 days vacation", "Should include specific policy details") + if !strings.Contains(result, "VACATION_POLICY") { + t.Error("Should include resource content") + } + if !strings.Contains(result, "20 days vacation") { + t.Error("Should include specific policy details") + } } // TestMCPURIMatching tests URI template matching edge cases. @@ -178,24 +207,34 @@ func TestMCPURIMatching(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/content_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // SETUP: Genkit with MCP g := genkit.Init(ctx) host, err := NewMCPHost(g, MCPHostOptions{Name: "test-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "content-server", MCPClientOptions{ Name: "content-server", Stdio: &StdioConfig{Command: serverBinary}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Get resources to test resources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) - assert.Greater(t, len(resources), 0, "Should have resources") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(resources) == 0 { + t.Error("Should have resources") + } // TEST: Edge cases that should work with our normalizeURI fixes testCases := []struct { @@ -219,7 +258,9 @@ func TestMCPURIMatching(t *testing.T) { break } } - assert.True(t, found, "URI %s should match template file://data/{filename}", tc.uri) + if !found { + t.Errorf("URI %s should match template file://data/{filename}", tc.uri) + } }) } } @@ -241,24 +282,34 @@ func TestMCPContentFetch(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/content_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // SETUP: Genkit with MCP g := genkit.Init(ctx) host, err := NewMCPHost(g, MCPHostOptions{Name: "test-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "content-server", MCPClientOptions{ Name: "content-server", Stdio: &StdioConfig{Command: serverBinary}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // TEST: Get resources and find matching one resources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) - assert.Greater(t, len(resources), 0, "Should have resources") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(resources) == 0 { + t.Error("Should have resources") + } // Find resource that matches our test URI testURI := "file://data/example.txt" @@ -271,7 +322,9 @@ func TestMCPContentFetch(t *testing.T) { } // ASSERT 1: Resource found - assert.NotNil(t, matchingResource, "Should find matching resource for %s", testURI) + if matchingResource == nil { + t.Fatalf("Should find matching resource for %s", testURI) + } // ASSERT 2: Content can be fetched via AI integration (end-to-end test) genkit.DefineModel(g, "echo-model", &ai.ModelOptions{ @@ -302,16 +355,26 @@ func TestMCPContentFetch(t *testing.T) { ) // ASSERT 3: Generation succeeds and includes resource content - assert.NoError(t, err) - assert.NotNil(t, resp) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if resp == nil { + t.Fatal("expected response, got nil") + } result := resp.Text() t.Logf("AI response with resource content: %s", result) // ASSERT 4: Content was fetched and included - assert.Contains(t, result, "CONTENT_FROM_SERVER", "Should include server identifier") - assert.Contains(t, result, "example.txt", "Should include the filename variable") - assert.Contains(t, result, "with important data.", "Should include expected content") + if !strings.Contains(result, "CONTENT_FROM_SERVER") { + t.Error("Should include server identifier") + } + if !strings.Contains(result, "example.txt") { + t.Error("Should include the filename variable") + } + if !strings.Contains(result, "with important data.") { + t.Error("Should include expected content") + } } // TestMCPMultipleServers tests connecting to multiple MCP servers simultaneously. @@ -332,37 +395,51 @@ func TestMCPMultipleServers(t *testing.T) { cmdA := exec.Command("go", "build", "-o", serverA, "./fixtures/server_a") err := cmdA.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } cmdB := exec.Command("go", "build", "-o", serverB, "./fixtures/server_b") err = cmdB.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // SETUP: Genkit with MCP host g := genkit.Init(ctx) host, err := NewMCPHost(g, MCPHostOptions{Name: "multi-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // CONNECT: To both servers err = host.Connect(ctx, g, "server-a", MCPClientOptions{ Name: "server-a", Stdio: &StdioConfig{Command: serverA}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "server-b", MCPClientOptions{ Name: "server-b", Stdio: &StdioConfig{Command: serverB}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // TEST: Get all resources from both servers allResources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // ASSERT: Resources from both servers are present - assert.GreaterOrEqual(t, len(allResources), 2, "Should have resources from both servers") + if len(allResources) < 2 { + t.Error("Should have resources from both servers") + } // ASSERT: Can identify resources from each server serverAResources := 0 @@ -373,17 +450,25 @@ func TestMCPMultipleServers(t *testing.T) { if strings.Contains(name, "server-a") { serverAResources++ // Test server A resource matches its URI pattern - assert.True(t, res.Matches("a://docs/test.md"), "Server A resource should match a:// pattern") + if !res.Matches("a://docs/test.md") { + t.Error("Server A resource should match a:// pattern") + } } else if strings.Contains(name, "server-b") { serverBResources++ // Test server B resource matches its URI pattern - assert.True(t, res.Matches("b://files/data.json"), "Server B resource should match b:// pattern") + if !res.Matches("b://files/data.json") { + t.Error("Server B resource should match b:// pattern") + } } } // ASSERT: Both servers contributed resources - assert.Greater(t, serverAResources, 0, "Should have resources from server A") - assert.Greater(t, serverBResources, 0, "Should have resources from server B") + if serverAResources == 0 { + t.Error("Should have resources from server A") + } + if serverBResources == 0 { + t.Error("Should have resources from server B") + } t.Logf("Found %d resources from server A, %d from server B", serverAResources, serverBResources) } @@ -406,7 +491,9 @@ func TestMCPErrorResilience(t *testing.T) { defer cancel() host, err := NewMCPHost(g, MCPHostOptions{Name: "error-test"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Try to connect to non-existent command err = host.Connect(ctx, g, "bad-server", MCPClientOptions{ @@ -415,7 +502,9 @@ func TestMCPErrorResilience(t *testing.T) { }) // ASSERT: Graceful failure, not crash (fails in ~100ms) - assert.Error(t, err) // Any connection failure is fine + if err == nil { + t.Error("expected error, got nil") + } t.Logf("Connection failure handled gracefully: %v", err) }) @@ -427,20 +516,28 @@ func TestMCPErrorResilience(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/basic_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } host, err := NewMCPHost(g, MCPHostOptions{Name: "test-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "test-server", MCPClientOptions{ Name: "test-server", Stdio: &StdioConfig{Command: serverBinary}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Try to find non-existent resource resources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Test URI that won't match any resource nonExistentURI := "file://nonexistent/path.txt" @@ -453,7 +550,9 @@ func TestMCPErrorResilience(t *testing.T) { } // ASSERT: Resource not found, but no crash - assert.False(t, found, "Non-existent resource should not match") + if found { + t.Error("Non-existent resource should not match") + } t.Logf("Resource not found handled gracefully for URI: %s", nonExistentURI) }) @@ -464,19 +563,27 @@ func TestMCPErrorResilience(t *testing.T) { cmd := exec.Command("go", "build", "-o", serverBinary, "./fixtures/basic_server") err := cmd.Run() - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } host, err := NewMCPHost(g, MCPHostOptions{Name: "test-host"}) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } err = host.Connect(ctx, g, "test-server", MCPClientOptions{ Name: "test-server", Stdio: &StdioConfig{Command: serverBinary}, }) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } resources, err := host.GetActiveResources(ctx) - assert.NoError(t, err) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } // Test various malformed URIs malformedURIs := []string{ diff --git a/go/plugins/postgresql/engine_test.go b/go/plugins/postgresql/engine_test.go index d40c34e841..79c756f109 100644 --- a/go/plugins/postgresql/engine_test.go +++ b/go/plugins/postgresql/engine_test.go @@ -19,7 +19,6 @@ import ( "testing" "github.com/jackc/pgx/v5/pgxpool" - "github.com/stretchr/testify/assert" ) func TestApplyEngineOptionsConfig(t *testing.T) { @@ -89,10 +88,16 @@ func TestApplyEngineOptionsConfig(t *testing.T) { t.Run(tc.name, func(t *testing.T) { cfg, err := applyEngineOptions(tc.opts) if tc.wantErr { - assert.Error(t, err) + if err == nil { + t.Error("expected error, got nil") + } } else { - assert.NoError(t, err) - assert.Equal(t, tc.wantIpType, cfg.ipType) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if got, want := cfg.ipType, tc.wantIpType; got != want { + t.Errorf("ipType = %v, want %v", got, want) + } } }) } @@ -132,11 +137,19 @@ func TestGetUser(t *testing.T) { ctx := context.Background() user, iamAuth, err := getUser(ctx, tc.cfg) if tc.wantErr { - assert.Error(t, err) + if err == nil { + t.Error("expected error, got nil") + } } else { - assert.NoError(t, err) - assert.Equal(t, tc.wantUser, user) - assert.Equal(t, tc.wantIAMAuth, iamAuth) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if got, want := user, tc.wantUser; got != want { + t.Errorf("user = %q, want %q", got, want) + } + if got, want := iamAuth, tc.wantIAMAuth; got != want { + t.Errorf("iamAuth = %v, want %v", got, want) + } } }) } diff --git a/go/plugins/postgresql/genkit_test.go b/go/plugins/postgresql/genkit_test.go index e03a4647f4..a20bc06c2e 100644 --- a/go/plugins/postgresql/genkit_test.go +++ b/go/plugins/postgresql/genkit_test.go @@ -24,8 +24,6 @@ import ( "github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/internal/fakeembedder" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) const ( @@ -158,9 +156,15 @@ func TestPostgres(t *testing.T) { if err != nil { t.Fatal(err) } - require.Len(t, resp.Documents, 3) - require.Len(t, resp.Documents[0].Content, 1) - assert.Equal(t, "hello1", resp.Documents[0].Content[0].Text) + if len(resp.Documents) != 3 { + t.Fatalf("expected 3 documents, got %d", len(resp.Documents)) + } + if len(resp.Documents[0].Content) != 1 { + t.Fatalf("expected 1 content part, got %d", len(resp.Documents[0].Content)) + } + if got, want := resp.Documents[0].Content[0].Text, "hello1"; got != want { + t.Errorf("got content %q, want %q", got, want) + } resp, err = retriever.Retrieve(ctx, &ai.RetrieverRequest{ Query: d1, @@ -172,9 +176,15 @@ func TestPostgres(t *testing.T) { t.Fatal(err) } - require.Len(t, resp.Documents, 1) - require.Len(t, resp.Documents[0].Content, 1) - assert.Equal(t, "hello2", resp.Documents[0].Content[0].Text) + if len(resp.Documents) != 1 { + t.Fatalf("expected 1 document, got %d", len(resp.Documents)) + } + if len(resp.Documents[0].Content) != 1 { + t.Fatalf("expected 1 content part, got %d", len(resp.Documents[0].Content)) + } + if got, want := resp.Documents[0].Content[0].Text, "hello2"; got != want { + t.Errorf("got content %q, want %q", got, want) + } } diff --git a/go/plugins/postgresql/indexer_test.go b/go/plugins/postgresql/indexer_test.go index 5a28c2f8e5..b544e62a3c 100644 --- a/go/plugins/postgresql/indexer_test.go +++ b/go/plugins/postgresql/indexer_test.go @@ -19,14 +19,14 @@ import ( "testing" "github.com/firebase/genkit/go/ai" - "github.com/stretchr/testify/require" ) func TestIndex_Success_NoDocuments(t *testing.T) { ds := DocStore{} err := ds.Index(context.Background(), nil) - require.NoError(t, err) - + if err != nil { + t.Errorf("unexpected error: %v", err) + } } func TestIndex_Fail_EmbedReturnError(t *testing.T) { @@ -44,5 +44,7 @@ func TestIndex_Fail_EmbedReturnError(t *testing.T) { }} err := ds.Index(context.Background(), docs) - require.Error(t, err) + if err == nil { + t.Error("expected error, got nil") + } } diff --git a/go/plugins/postgresql/retriever_test.go b/go/plugins/postgresql/retriever_test.go index 18641d5ca6..ce35fc4b23 100644 --- a/go/plugins/postgresql/retriever_test.go +++ b/go/plugins/postgresql/retriever_test.go @@ -16,19 +16,24 @@ package postgresql import ( "context" + "strings" "testing" "github.com/firebase/genkit/go/ai" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRetriever_Fail_WrongTypeOfOption(t *testing.T) { ds := DocStore{} res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{Options: struct{}{}}) - require.Nil(t, res) - require.Error(t, err) - assert.ErrorContains(t, err, "postgres.Retrieve options have type") + if res != nil { + t.Errorf("Retrieve() res = %v, want nil", res) + } + if err == nil { + t.Fatal("Retrieve() expected error, got nil") + } + if want := "postgres.Retrieve options have type"; !strings.Contains(err.Error(), want) { + t.Errorf("Retrieve() error = %q, want it to contain %q", err.Error(), want) + } } func TestRetriever_Fail_EmbedReturnError(t *testing.T) { @@ -36,6 +41,10 @@ func TestRetriever_Fail_EmbedReturnError(t *testing.T) { config: &Config{Embedder: mockEmbedderFail{}}, } res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{}) - require.Nil(t, res) - require.Error(t, err) + if res != nil { + t.Errorf("Retrieve() res = %v, want nil", res) + } + if err == nil { + t.Error("Retrieve() expected error, got nil") + } } diff --git a/go/plugins/vertexai/vectorsearch/vectorsearch_test.go b/go/plugins/vertexai/vectorsearch/vectorsearch_test.go index a847e1f2f2..816bf8ef70 100644 --- a/go/plugins/vertexai/vectorsearch/vectorsearch_test.go +++ b/go/plugins/vertexai/vectorsearch/vectorsearch_test.go @@ -19,11 +19,11 @@ import ( "errors" "net/http" "os" + "strings" "testing" "github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/core/api" - "github.com/stretchr/testify/assert" ) type fakeEmbedder struct { @@ -48,7 +48,9 @@ func (f *fakeEmbedder) Register(r api.Registry) { func TestVectorsearch_Name(t *testing.T) { v := &VertexAIVectorSearch{} - assert.Equal(t, vectorsearchProvider, v.Name()) + if got, want := v.Name(), vectorsearchProvider; got != want { + t.Errorf("Name() = %q, want %q", got, want) + } } // ---------- tests: Init ---------- @@ -56,10 +58,12 @@ func TestVectorsearch_Name(t *testing.T) { func TestInit_AlreadyInitialized(t *testing.T) { v := &VertexAIVectorSearch{initted: true} - // Use assert.Panics to check for panic - assert.Panics(t, func() { - v.Init(context.Background()) - }, "Expected Init to panic when the plugin is already initialized") + defer func() { + if r := recover(); r == nil { + t.Errorf("Expected Init to panic when the plugin is already initialized") + } + }() + v.Init(context.Background()) } func TestInit_MissingProjectID_Panics(t *testing.T) { @@ -86,10 +90,12 @@ func TestInit_MissingProjectID_Panics(t *testing.T) { v := &VertexAIVectorSearch{} - // Use assert.Panics to check for panic - assert.Panics(t, func() { - v.Init(context.Background()) - }, "Expected Init to panic when GOOGLE_CLOUD_PROJECT is not set") + defer func() { + if r := recover(); r == nil { + t.Errorf("Expected Init to panic when GOOGLE_CLOUD_PROJECT is not set") + } + }() + v.Init(context.Background()) } func TestInit_MissingLocation_Panics(t *testing.T) { @@ -102,16 +108,20 @@ func TestInit_MissingLocation_Panics(t *testing.T) { v := &VertexAIVectorSearch{} - // Use assert.Panics to check for panic - assert.Panics(t, func() { - v.Init(context.Background()) - }, "Expected Init to panic when GOOGLE_CLOUD_LOCATION is not set") + defer func() { + if r := recover(); r == nil { + t.Errorf("Expected Init to panic when GOOGLE_CLOUD_LOCATION is not set") + } + }() + v.Init(context.Background()) } func setEnv(t *testing.T, k, v string) func() { t.Helper() old, had := os.LookupEnv(k) - assert.NoError(t, os.Setenv(k, v)) + if err := os.Setenv(k, v); err != nil { + t.Fatal(err) + } return func() { if had { _ = os.Setenv(k, old) @@ -145,12 +155,18 @@ func TestRetrieve_Success(t *testing.T) { v := newVSWithToken("tok123", nil) findNeighborsJSON := `{"nearestNeighbors":[{"neighbors":[{"datapoint":{"datapointId":"doc-1"},"distance":0.4}]}]}` withTransport(t, rtFunc(func(r *http.Request) (*http.Response, error) { - assert.Equal(t, "Bearer tok123", r.Header.Get("Authorization")) + if got, want := r.Header.Get("Authorization"), "Bearer tok123"; got != want { + t.Errorf("Authorization header = %q, want %q", got, want) + } return newHTTPResponse(http.StatusOK, findNeighborsJSON), nil }), func() { docRetriever := func(ctx context.Context, neighbors []Neighbor, options any) ([]*ai.Document, error) { - assert.Len(t, neighbors, 1) - assert.Equal(t, "doc-1", neighbors[0].Datapoint.DatapointId) + if len(neighbors) != 1 { + t.Errorf("len(neighbors) = %d, want 1", len(neighbors)) + } + if got, want := neighbors[0].Datapoint.DatapointId, "doc-1"; got != want { + t.Errorf("datapointId = %q, want %q", got, want) + } return []*ai.Document{{Content: []*ai.Part{{Text: "Hello"}}}}, nil } @@ -168,9 +184,15 @@ func TestRetrieve_Success(t *testing.T) { } resp, err := v.Retrieve(context.Background(), req) - assert.NoError(t, err) - assert.NotNil(t, resp) - assert.Equal(t, "Hello", resp.Documents[0].Content[0].Text) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if resp == nil { + t.Fatal("expected response, got nil") + } + if got, want := resp.Documents[0].Content[0].Text, "Hello"; got != want { + t.Errorf("document content = %q, want %q", got, want) + } }) } @@ -186,8 +208,12 @@ func TestRetrieve_EmbedderError(t *testing.T) { }, } _, err := v.Retrieve(context.Background(), req) - assert.Error(t, err) - assert.Contains(t, err.Error(), "error generating embedding for query") + if err == nil { + t.Error("expected error, got nil") + } + if want := "error generating embedding for query"; !strings.Contains(err.Error(), want) { + t.Errorf("error = %q, want it to contain %q", err.Error(), want) + } } func TestRetrieve_NoEmbeddings(t *testing.T) { @@ -202,8 +228,12 @@ func TestRetrieve_NoEmbeddings(t *testing.T) { }, } _, err := v.Retrieve(context.Background(), req) - assert.Error(t, err) - assert.Contains(t, err.Error(), "no embeddings generated for query") + if err == nil { + t.Error("expected error, got nil") + } + if want := "no embeddings generated for query"; !strings.Contains(err.Error(), want) { + t.Errorf("error = %q, want it to contain %q", err.Error(), want) + } } func TestRetrieve_NoNeighborsReturnsNil(t *testing.T) { @@ -223,7 +253,11 @@ func TestRetrieve_NoNeighborsReturnsNil(t *testing.T) { }, } resp, err := v.Retrieve(context.Background(), req) - assert.NoError(t, err) - assert.Nil(t, resp) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if resp != nil { + t.Errorf("Retrieve() resp = %v, want nil", resp) + } }) } diff --git a/go/plugins/weaviate/weaviate_test.go b/go/plugins/weaviate/weaviate_test.go index 7394ae8b1c..4b5fe7eea2 100644 --- a/go/plugins/weaviate/weaviate_test.go +++ b/go/plugins/weaviate/weaviate_test.go @@ -26,7 +26,6 @@ import ( "github.com/firebase/genkit/go/core" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/internal/fakeembedder" - "github.com/stretchr/testify/assert" ) var ( @@ -80,7 +79,9 @@ func TestGenkit(t *testing.T) { } actions := w.Init(ctx) - assert.Empty(t, actions) + if len(actions) != 0 { + t.Errorf("actions = %v, want empty", actions) + } // Delete our test class so that earlier runs don't mess us up. if err := w.client.Schema().ClassDeleter().WithClassName(*testClass).Do(ctx); err != nil { diff --git a/go/samples/mcp-git-pr-explainer/go.mod b/go/samples/mcp-git-pr-explainer/go.mod index 4a19281a89..32e0e501f4 100644 --- a/go/samples/mcp-git-pr-explainer/go.mod +++ b/go/samples/mcp-git-pr-explainer/go.mod @@ -43,7 +43,7 @@ require ( golang.org/x/net v0.41.0 // indirect golang.org/x/sys v0.34.0 // indirect golang.org/x/text v0.27.0 // indirect - google.golang.org/genai v1.40.0 // indirect + google.golang.org/genai v1.41.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect google.golang.org/grpc v1.73.0 // indirect google.golang.org/protobuf v1.36.6 // indirect diff --git a/go/samples/mcp-git-pr-explainer/go.sum b/go/samples/mcp-git-pr-explainer/go.sum index b8b244b3cb..725d7191d8 100644 --- a/go/samples/mcp-git-pr-explainer/go.sum +++ b/go/samples/mcp-git-pr-explainer/go.sum @@ -9,8 +9,8 @@ github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xW github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -50,9 +50,8 @@ github.com/mark3labs/mcp-go v0.29.0 h1:sH1NBcumKskhxqYzhXfGc201D7P76TVXiT0fGVhab github.com/mark3labs/mcp-go v0.29.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4= github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a h1:v2cBA3xWKv2cIOVhnzX/gNgkNXqiHfUgJtA3r61Hf7A= github.com/mbleigh/raymond v0.0.0-20250414171441-6b3a58ab9e0a/go.mod h1:Y6ghKH+ZijXn5d9E7qGGZBmjitx7iitZdQiIW97EpTU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= @@ -98,8 +97,8 @@ golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -google.golang.org/genai v1.40.0 h1:kYxyQSH+vsib8dvsgyLJzsVEIv5k3ZmHJyVqdvGncmc= -google.golang.org/genai v1.40.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= +google.golang.org/genai v1.41.0 h1:ayXl75LjTmqTu0y94yr96d17gIb4zF8gWVzX2TgioEY= +google.golang.org/genai v1.41.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE= google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok= diff --git a/go/samples/telemetry-test/kitchen_sink/go.mod b/go/samples/telemetry-test/kitchen_sink/go.mod index be248881d0..b50fe50509 100644 --- a/go/samples/telemetry-test/kitchen_sink/go.mod +++ b/go/samples/telemetry-test/kitchen_sink/go.mod @@ -8,7 +8,7 @@ replace github.com/firebase/genkit/go => ../../../ require ( github.com/firebase/genkit/go v0.0.0-00010101000000-000000000000 - google.golang.org/genai v1.30.0 + google.golang.org/genai v1.41.0 ) require ( diff --git a/go/samples/telemetry-test/kitchen_sink/go.sum b/go/samples/telemetry-test/kitchen_sink/go.sum index 122a1febd0..e5ef3c4b4e 100644 --- a/go/samples/telemetry-test/kitchen_sink/go.sum +++ b/go/samples/telemetry-test/kitchen_sink/go.sum @@ -196,8 +196,8 @@ google.golang.org/api v0.236.0 h1:CAiEiDVtO4D/Qja2IA9VzlFrgPnK3XVMmRoJZlSWbc0= google.golang.org/api v0.236.0/go.mod h1:X1WF9CU2oTc+Jml1tiIxGmWFK/UZezdqEu09gcxZAj4= google.golang.org/appengine/v2 v2.0.6 h1:LvPZLGuchSBslPBp+LAhihBeGSiRh1myRoYK4NtuBIw= google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7Z1JKf3J3wLI= -google.golang.org/genai v1.30.0 h1:7021aneIvl24nEBLbtQFEWleHsMbjzpcQvkT4WcJ1dc= -google.golang.org/genai v1.30.0/go.mod h1:7pAilaICJlQBonjKKJNhftDFv3SREhZcTe9F6nRcjbg= +google.golang.org/genai v1.41.0 h1:ayXl75LjTmqTu0y94yr96d17gIb4zF8gWVzX2TgioEY= +google.golang.org/genai v1.41.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 h1:1tXaIXCracvtsRxSBsYDiSBN0cuJvM7QYW+MrpIRY78= google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:49MsLSx0oWMOZqcpB3uL8ZOkAh1+TndpJ8ONoCBWiZk= google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ= diff --git a/go/samples/telemetry-test/simple/go.mod b/go/samples/telemetry-test/simple/go.mod index c3cc3964b0..100a4114ac 100644 --- a/go/samples/telemetry-test/simple/go.mod +++ b/go/samples/telemetry-test/simple/go.mod @@ -8,7 +8,7 @@ replace github.com/firebase/genkit/go => ../../../ require ( github.com/firebase/genkit/go v0.0.0-00010101000000-000000000000 - google.golang.org/genai v1.30.0 + google.golang.org/genai v1.41.0 ) require ( diff --git a/go/samples/telemetry-test/simple/go.sum b/go/samples/telemetry-test/simple/go.sum index 122a1febd0..e5ef3c4b4e 100644 --- a/go/samples/telemetry-test/simple/go.sum +++ b/go/samples/telemetry-test/simple/go.sum @@ -196,8 +196,8 @@ google.golang.org/api v0.236.0 h1:CAiEiDVtO4D/Qja2IA9VzlFrgPnK3XVMmRoJZlSWbc0= google.golang.org/api v0.236.0/go.mod h1:X1WF9CU2oTc+Jml1tiIxGmWFK/UZezdqEu09gcxZAj4= google.golang.org/appengine/v2 v2.0.6 h1:LvPZLGuchSBslPBp+LAhihBeGSiRh1myRoYK4NtuBIw= google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7Z1JKf3J3wLI= -google.golang.org/genai v1.30.0 h1:7021aneIvl24nEBLbtQFEWleHsMbjzpcQvkT4WcJ1dc= -google.golang.org/genai v1.30.0/go.mod h1:7pAilaICJlQBonjKKJNhftDFv3SREhZcTe9F6nRcjbg= +google.golang.org/genai v1.41.0 h1:ayXl75LjTmqTu0y94yr96d17gIb4zF8gWVzX2TgioEY= +google.golang.org/genai v1.41.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 h1:1tXaIXCracvtsRxSBsYDiSBN0cuJvM7QYW+MrpIRY78= google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:49MsLSx0oWMOZqcpB3uL8ZOkAh1+TndpJ8ONoCBWiZk= google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ= From 74afd91154a5e3cd0d08e881e3316e2dfd739cde Mon Sep 17 00:00:00 2001 From: Hugo Aguirre Parra Date: Thu, 29 Jan 2026 19:39:31 +0000 Subject: [PATCH 2/2] fix: fail-fast test cases --- go/plugins/alloydb/retriever_test.go | 4 ++-- go/plugins/postgresql/indexer_test.go | 4 ++-- go/plugins/postgresql/retriever_test.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go/plugins/alloydb/retriever_test.go b/go/plugins/alloydb/retriever_test.go index d102435a47..f3e77e43ef 100644 --- a/go/plugins/alloydb/retriever_test.go +++ b/go/plugins/alloydb/retriever_test.go @@ -42,9 +42,9 @@ func TestRetriever_Fail_EmbedReturnError(t *testing.T) { } res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{}) if res != nil { - t.Errorf("Retrieve() res = %v, want nil", res) + t.Fatalf("Retrieve() res = %v, want nil", res) } if err == nil { - t.Error("Retrieve() expected error, got nil") + t.Fatal("Retrieve() expected error, got nil") } } diff --git a/go/plugins/postgresql/indexer_test.go b/go/plugins/postgresql/indexer_test.go index b544e62a3c..90f9d121cc 100644 --- a/go/plugins/postgresql/indexer_test.go +++ b/go/plugins/postgresql/indexer_test.go @@ -25,7 +25,7 @@ func TestIndex_Success_NoDocuments(t *testing.T) { ds := DocStore{} err := ds.Index(context.Background(), nil) if err != nil { - t.Errorf("unexpected error: %v", err) + t.Fatalf("unexpected error: %v", err) } } @@ -45,6 +45,6 @@ func TestIndex_Fail_EmbedReturnError(t *testing.T) { err := ds.Index(context.Background(), docs) if err == nil { - t.Error("expected error, got nil") + t.Fatal("expected error, got nil") } } diff --git a/go/plugins/postgresql/retriever_test.go b/go/plugins/postgresql/retriever_test.go index ce35fc4b23..a26caa3663 100644 --- a/go/plugins/postgresql/retriever_test.go +++ b/go/plugins/postgresql/retriever_test.go @@ -26,7 +26,7 @@ func TestRetriever_Fail_WrongTypeOfOption(t *testing.T) { ds := DocStore{} res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{Options: struct{}{}}) if res != nil { - t.Errorf("Retrieve() res = %v, want nil", res) + t.Fatalf("Retrieve() res = %v, want nil", res) } if err == nil { t.Fatal("Retrieve() expected error, got nil") @@ -42,9 +42,9 @@ func TestRetriever_Fail_EmbedReturnError(t *testing.T) { } res, err := ds.Retrieve(context.Background(), &ai.RetrieverRequest{}) if res != nil { - t.Errorf("Retrieve() res = %v, want nil", res) + t.Fatalf("Retrieve() res = %v, want nil", res) } if err == nil { - t.Error("Retrieve() expected error, got nil") + t.Fatal("Retrieve() expected error, got nil") } }