diff options
Diffstat (limited to 'builder/builder_test.go')
| -rw-r--r-- | builder/builder_test.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/builder/builder_test.go b/builder/builder_test.go index 450aca9..6be142d 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -1,22 +1,34 @@ package builder import ( - "encoding/json" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/xlgmokha/openapi/test" ) func TestBuilder(t *testing.T) { t.Run("builds a minimal spec", func(t *testing.T) { + spec := New("The API", "0.1.0").Build() + + assert.Equal(t, + test.Fixture("minimal.json"), + spec.ToJSON(), + ) + }) + + t.Run("adds a path", func(t *testing.T) { builder := New("The API", "0.1.0") - spec := builder.Build() + builder.AddPath("/users").Get( + "List all the users", + "List all the users", + ) - bytes, err := json.MarshalIndent(spec, "", " ") - require.Nil(t, err) + spec := builder.Build() - assert.Equal(t, test.Fixture("minimal.json"), string(bytes)) + assert.Equal(t, + test.Fixture("users.json"), + spec.ToJSON(), + ) }) } |
