diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-02 17:03:40 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-09 12:51:45 +0000 |
| commit | 45d8f079628d0d9c0214c07e1abe9e8cb26057d6 (patch) | |
| tree | c7b6e95f040cbbf1322de719360bfe573740272c /pkg/aflow/schema_test.go | |
| parent | ce25ef79a77633ecbd0042eb35c9432dd582d448 (diff) | |
pkg/aflow: add package for agentic workflows
Diffstat (limited to 'pkg/aflow/schema_test.go')
| -rw-r--r-- | pkg/aflow/schema_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/pkg/aflow/schema_test.go b/pkg/aflow/schema_test.go new file mode 100644 index 000000000..ac441f7d6 --- /dev/null +++ b/pkg/aflow/schema_test.go @@ -0,0 +1,50 @@ +// Copyright 2025 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package aflow + +import ( + "fmt" + "testing" + + "github.com/google/jsonschema-go/jsonschema" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestSchema(t *testing.T) { + type Test struct { + fn func() (*jsonschema.Schema, error) + err string + } + type structWithNoTags struct { + A int + } + type structWithTags struct { + A int `jsonschema:"aaa"` + B string `jsonschema:"bbb"` + } + tests := []Test{ + { + fn: schemaFor[int], + err: "int is not a struct", + }, + { + fn: schemaFor[structWithNoTags], + err: "structWithNoTags.A does not have a jsonschema tag with description", + }, + { + fn: schemaFor[structWithTags], + }, + } + for i, test := range tests { + t.Run(fmt.Sprint(i), func(t *testing.T) { + _, err := test.fn() + if err != nil { + assert.Equal(t, err.Error(), test.err) + return + } + require.Empty(t, test.err) + }) + } +} |
