Skip to content

Commit

Permalink
Tests were hanging, stopped JSON parsing channel use altogether
Browse files Browse the repository at this point in the history
vacuum will need looking at for this later version.
  • Loading branch information
daveshanley committed Dec 13, 2022
1 parent 724fdb3 commit ece888d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
7 changes: 2 additions & 5 deletions datamodel/spec_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 0 additions & 7 deletions datamodel/spec_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)

}
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
10 changes: 0 additions & 10 deletions document.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ece888d

Please sign in to comment.