mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
All tests in index and datamodel now pass. The rolodex fixes all the things. Signed-off-by: quobix <dave@quobix.com>
46 lines
870 B
Go
46 lines
870 B
Go
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v2
|
|
|
|
import (
|
|
"context"
|
|
"github.com/pb33f/libopenapi/datamodel/low"
|
|
v2 "github.com/pb33f/libopenapi/datamodel/low/v2"
|
|
"github.com/pb33f/libopenapi/index"
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v3"
|
|
"testing"
|
|
)
|
|
|
|
func TestPathItem_GetOperations(t *testing.T) {
|
|
|
|
yml := `get:
|
|
description: get
|
|
put:
|
|
description: put
|
|
post:
|
|
description: post
|
|
patch:
|
|
description: patch
|
|
delete:
|
|
description: delete
|
|
head:
|
|
description: head
|
|
options:
|
|
description: options
|
|
`
|
|
|
|
var idxNode yaml.Node
|
|
_ = yaml.Unmarshal([]byte(yml), &idxNode)
|
|
idx := index.NewSpecIndex(&idxNode)
|
|
|
|
var n v2.PathItem
|
|
_ = low.BuildModel(&idxNode, &n)
|
|
_ = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
|
|
|
r := NewPathItem(&n)
|
|
|
|
assert.Len(t, r.GetOperations(), 7)
|
|
}
|