mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
added coverage for fixed remote unsupported handler
Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -314,15 +314,9 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
|
|||||||
return wait.file, nil
|
return wait.file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
processingWaiter := &waiterRemote{f: remoteParsedURL.Path}
|
|
||||||
|
|
||||||
// add to processing
|
|
||||||
i.ProcessingFiles.Store(remoteParsedURL.Path, processingWaiter)
|
|
||||||
|
|
||||||
fileExt := ExtractFileType(remoteParsedURL.Path)
|
fileExt := ExtractFileType(remoteParsedURL.Path)
|
||||||
|
|
||||||
if fileExt == UNSUPPORTED {
|
if fileExt == UNSUPPORTED {
|
||||||
i.ProcessingFiles.Delete(remoteParsedURL.Path)
|
|
||||||
i.remoteErrors = append(i.remoteErrors, fs.ErrInvalid)
|
i.remoteErrors = append(i.remoteErrors, fs.ErrInvalid)
|
||||||
if i.logger != nil {
|
if i.logger != nil {
|
||||||
i.logger.Warn("[rolodex remote loader] unsupported file in reference will be ignored", "file", remoteURL, "remoteURL", remoteParsedURL.String())
|
i.logger.Warn("[rolodex remote loader] unsupported file in reference will be ignored", "file", remoteURL, "remoteURL", remoteParsedURL.String())
|
||||||
@@ -330,6 +324,11 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
|
|||||||
return nil, &fs.PathError{Op: "open", Path: remoteURL, Err: fs.ErrInvalid}
|
return nil, &fs.PathError{Op: "open", Path: remoteURL, Err: fs.ErrInvalid}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processingWaiter := &waiterRemote{f: remoteParsedURL.Path}
|
||||||
|
|
||||||
|
// add to processing
|
||||||
|
i.ProcessingFiles.Store(remoteParsedURL.Path, processingWaiter)
|
||||||
|
|
||||||
// if the remote URL is absolute (http:// or https://), and we have a rootURL defined, we need to override
|
// if the remote URL is absolute (http:// or https://), and we have a rootURL defined, we need to override
|
||||||
// the host being defined by this URL, and use the rootURL instead, but keep the path.
|
// the host being defined by this URL, and use the rootURL instead, but keep the path.
|
||||||
if i.rootURLParsed != nil {
|
if i.rootURLParsed != nil {
|
||||||
|
|||||||
@@ -397,3 +397,14 @@ func TestNewRemoteFS_RemoteBaseURL_EmptySpecFailIndex(t *testing.T) {
|
|||||||
assert.Error(t, y)
|
assert.Error(t, y)
|
||||||
assert.Equal(t, "there is nothing in the spec, it's empty - so there is nothing to be done", y.Error())
|
assert.Equal(t, "there is nothing in the spec, it's empty - so there is nothing to be done", y.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewRemoteFS_Unsupported(t *testing.T) {
|
||||||
|
|
||||||
|
cf := CreateOpenAPIIndexConfig()
|
||||||
|
rfs, _ := NewRemoteFSWithConfig(cf)
|
||||||
|
|
||||||
|
x, y := rfs.Open("/woof.png")
|
||||||
|
assert.Nil(t, x)
|
||||||
|
assert.Error(t, y)
|
||||||
|
assert.Equal(t, "open /woof.png: invalid argument", y.Error())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user