Merged in jb/openapi (pull request #22)
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
This commit is contained in:
committed by
Michael McGuinness
parent
5ca36b0502
commit
174644b63c
@@ -0,0 +1,92 @@
|
||||
package queryservice
|
||||
|
||||
import (
|
||||
"queryorchestration/internal/query"
|
||||
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseQueries(t *testing.T) {
|
||||
in := []*query.Query{
|
||||
{
|
||||
ID: uuid.New(),
|
||||
Type: queryprocessor.TypeContextFull,
|
||||
ActiveVersion: 1,
|
||||
LatestVersion: 2,
|
||||
RequiredQueryIDs: []uuid.UUID{
|
||||
uuid.New(),
|
||||
},
|
||||
Config: "hey",
|
||||
},
|
||||
}
|
||||
out, err := parseQueries(in)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, out, len(in))
|
||||
assert.ElementsMatch(t, []Query{
|
||||
{
|
||||
Id: in[0].ID.String(),
|
||||
Type: CONTEXTFULL,
|
||||
ActiveVersion: 1,
|
||||
LatestVersion: 2,
|
||||
RequiredQueries: []string{
|
||||
in[0].RequiredQueryIDs[0].String(),
|
||||
},
|
||||
Config: &in[0].Config,
|
||||
},
|
||||
}, out)
|
||||
}
|
||||
|
||||
func TestParseQuery(t *testing.T) {
|
||||
in := &query.Query{
|
||||
ID: uuid.New(),
|
||||
Type: queryprocessor.TypeContextFull,
|
||||
ActiveVersion: 1,
|
||||
LatestVersion: 2,
|
||||
RequiredQueryIDs: []uuid.UUID{
|
||||
uuid.New(),
|
||||
},
|
||||
Config: "hey",
|
||||
}
|
||||
out, err := parseQuery(in)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, Query{
|
||||
Id: in.ID.String(),
|
||||
Type: CONTEXTFULL,
|
||||
ActiveVersion: 1,
|
||||
LatestVersion: 2,
|
||||
RequiredQueries: []string{
|
||||
in.RequiredQueryIDs[0].String(),
|
||||
},
|
||||
Config: &in.Config,
|
||||
},
|
||||
*out)
|
||||
}
|
||||
|
||||
func TestParseQueryType(t *testing.T) {
|
||||
qt, err := parseQueryType(queryprocessor.TypeContextFull)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, CONTEXTFULL, qt)
|
||||
|
||||
qt, err = parseQueryType(queryprocessor.TypeJsonExtractor)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, JSONEXTRACTOR, qt)
|
||||
|
||||
_, err = parseQueryType(queryprocessor.Type(-1))
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestParseSpecQueryType(t *testing.T) {
|
||||
qt, err := parseSpecQueryType(CONTEXTFULL)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeContextFull), qt)
|
||||
|
||||
qt, err = parseSpecQueryType(JSONEXTRACTOR)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeJsonExtractor), qt)
|
||||
|
||||
_, err = parseSpecQueryType("invalid")
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user