Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions go/genkit/dev_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"encoding/json"
"io"
"maps"
"net/http"
"net/http/httptest"
"strings"
Expand All @@ -27,6 +26,7 @@ import (
"github.com/firebase/genkit/go/internal/tracing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/invopop/jsonschema"
)

func dec(_ context.Context, x int) (int, error) {
Expand Down Expand Up @@ -84,11 +84,24 @@ func TestDevServer(t *testing.T) {
t.Fatal(err)
}
want := map[string]actionDesc{
"/test/devServer/inc": {Key: "/test/devServer/inc", Name: "inc", Metadata: map[string]any{"inputSchema": nil, "outputSchema": nil, "foo": "bar"}},
"/test/devServer/dec": {Key: "/test/devServer/dec", Name: "dec", Metadata: map[string]any{"inputSchema": nil, "outputSchema": nil, "bar": "baz"}},
"/test/devServer/inc": {
Key: "/test/devServer/inc",
Name: "inc",
InputSchema: &jsonschema.Schema{Type: "integer"},
OutputSchema: &jsonschema.Schema{Type: "integer"},
Metadata: map[string]any{"foo": "bar"},
},
"/test/devServer/dec": {
Key: "/test/devServer/dec",
InputSchema: &jsonschema.Schema{Type: "integer"},
OutputSchema: &jsonschema.Schema{Type: "integer"},
Name: "dec",
Metadata: map[string]any{"bar": "baz"},
},
}
if !maps.EqualFunc(got, want, actionDesc.equal) {
t.Errorf("\n got %v\nwant %v", got, want)
diff := cmp.Diff(want, got, cmpopts.IgnoreUnexported(jsonschema.Schema{}))
if diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}
})
t.Run("list traces", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go/genkit/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (f *Flow[I, O, S]) action() *Action[*flowInstruction[I], *flowState[I, O],
"outputSchema": inferJSONSchema(o),
}
return NewStreamingAction(f.name, metadata, func(ctx context.Context, inst *flowInstruction[I], cb StreamingCallback[S]) (*flowState[I, O], error) {
spanMetaKey.fromContext(ctx).SetAttr("flow:wrapperAction", "true")
tracing.SpanMetaKey.FromContext(ctx).SetAttr("flow:wrapperAction", "true")
return f.runInstruction(ctx, inst, cb)
})
}
Expand Down