Tests were hanging, stopped JSON parsing channel use altogether

vacuum will need looking at for this later version.
This commit is contained in:
Dave Shanley
2022-12-13 14:09:15 -05:00
parent 724fdb31c4
commit ece888d201
3 changed files with 2 additions and 22 deletions

View File

@@ -105,8 +105,7 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
spec.SpecJSONBytes = &bytes
spec.SpecJSON = &jsonSpec
}
spec.JsonParsingChannel <- true
close(spec.JsonParsingChannel)
close(spec.JsonParsingChannel) // this needs removing at some point
}
// check for specific keys
@@ -129,8 +128,6 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
specVersion.SpecFormat = OAS3
}
//return specVersion, nil
if openAPI2 != nil {
specVersion.SpecType = utils.OpenApi2
version, majorVersion, versionError := parseVersionTypeData(openAPI2.Value)
@@ -172,10 +169,10 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
if specVersion.SpecType == "" {
// parse JSON
parseJSON(spec, specVersion, &parsedSpec)
specVersion.Error = errors.New("spec type not supported by vacuum, sorry")
return specVersion, specVersion.Error
}
return specVersion, nil
}

View File

@@ -115,7 +115,6 @@ info:
func TestExtractSpecInfo_ValidJSON(t *testing.T) {
r, e := ExtractSpecInfo([]byte(goodJSON))
<-r.JsonParsingChannel
assert.Greater(t, len(*r.SpecJSONBytes), 0)
assert.Error(t, e)
}
@@ -132,7 +131,6 @@ func TestExtractSpecInfo_Nothing(t *testing.T) {
func TestExtractSpecInfo_ValidYAML(t *testing.T) {
r, e := ExtractSpecInfo([]byte(goodYAML))
<-r.JsonParsingChannel
assert.Greater(t, len(*r.SpecJSONBytes), 0)
assert.Error(t, e)
}
@@ -153,8 +151,6 @@ func TestExtractSpecInfo_OpenAPI3(t *testing.T) {
assert.Nil(t, e)
assert.Equal(t, utils.OpenApi3, r.SpecType)
assert.Equal(t, "3.0.1", r.Version)
<-r.JsonParsingChannel
assert.Greater(t, len(*r.SpecJSONBytes), 0)
}
@@ -188,8 +184,6 @@ func TestExtractSpecInfo_OpenAPI2(t *testing.T) {
assert.Nil(t, e)
assert.Equal(t, OpenApi2, r.SpecType)
assert.Equal(t, "2.0.1", r.Version)
<-r.JsonParsingChannel
assert.Greater(t, len(*r.SpecJSONBytes), 0)
}
@@ -207,7 +201,6 @@ func TestExtractSpecInfo_AsyncAPI(t *testing.T) {
assert.Nil(t, e)
assert.Equal(t, AsyncApi, r.SpecType)
assert.Equal(t, "2.0.0", r.Version)
<-r.JsonParsingChannel
assert.Greater(t, len(*r.SpecJSONBytes), 0)
}

View File

@@ -84,16 +84,6 @@ func NewDocument(specByteArray []byte) (Document, error) {
d := new(document)
d.version = info.Version
d.info = info
// wait for json to be ready
// this needs to be deprecated at some-point
done := false
for !done {
select {
case <-info.JsonParsingChannel:
done = true
}
}
return d, nil
}