-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Reuven
committed
Sep 27, 2023
1 parent
4fcbb57
commit 36582ab
Showing
10 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package load_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/load" | ||
) | ||
|
||
func TestLoadSpecInfo(t *testing.T) { | ||
_, err := load.LoadSpecInfo(MockLoader{}, "openapi-test1.yaml") | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestLoadGlob_OK(t *testing.T) { | ||
_, err := load.FromGlob(MockLoader{}, RelativeDataPath+"*.yaml") | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestLoadGlob_InvalidSpec(t *testing.T) { | ||
_, err := load.FromGlob(MockLoader{}, RelativeDataPath+"ignore-err-example.txt") | ||
require.Error(t, err) | ||
require.Equal(t, "error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type openapi3.TBis", err.Error()) | ||
} | ||
|
||
func TestLoadGlob_Invalid(t *testing.T) { | ||
_, err := load.FromGlob(MockLoader{}, "[*") | ||
require.Error(t, err) | ||
require.Equal(t, "syntax error in pattern", err.Error()) | ||
} | ||
|
||
func TestLoadGlob_URL(t *testing.T) { | ||
_, err := load.FromGlob(MockLoader{}, "http://localhost/openapi-test1.yaml") | ||
require.Error(t, err) | ||
require.Equal(t, "no matching files (should be a glob, not a URL)", err.Error()) | ||
} | ||
|
||
func TestLoadGlob_NoFiles(t *testing.T) { | ||
_, err := load.FromGlob(MockLoader{}, RelativeDataPath+"*.xxx") | ||
require.Error(t, err) | ||
require.Equal(t, "no matching files", err.Error()) | ||
} |