-
Notifications
You must be signed in to change notification settings - Fork 62
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 Harrison
authored
Nov 19, 2023
1 parent
66b7f71
commit ba83377
Showing
22 changed files
with
391 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package checker_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker" | ||
) | ||
|
||
var apiChange = checker.ApiChange{ | ||
Id: "id", | ||
Text: "text", | ||
Comment: "comment", | ||
Level: checker.ERR, | ||
Operation: "GET", | ||
OperationId: "123", | ||
Path: "/test", | ||
Source: "source", | ||
SourceFile: "sourceFile", | ||
SourceLine: 1, | ||
SourceLineEnd: 2, | ||
SourceColumn: 3, | ||
SourceColumnEnd: 4, | ||
} | ||
|
||
func TestApiChange(t *testing.T) { | ||
require.Equal(t, "id", apiChange.GetId()) | ||
require.Equal(t, "text", apiChange.GetText()) | ||
require.Equal(t, "comment", apiChange.GetComment()) | ||
require.Equal(t, checker.ERR, apiChange.GetLevel()) | ||
require.Equal(t, "GET", apiChange.GetOperation()) | ||
require.Equal(t, "123", apiChange.GetOperationId()) | ||
require.Equal(t, "/test", apiChange.GetPath()) | ||
require.Equal(t, "sourceFile", apiChange.GetSourceFile()) | ||
require.Equal(t, 1, apiChange.GetSourceLine()) | ||
require.Equal(t, 2, apiChange.GetSourceLineEnd()) | ||
require.Equal(t, 3, apiChange.GetSourceColumn()) | ||
require.Equal(t, 4, apiChange.GetSourceColumnEnd()) | ||
require.Equal(t, "error at source, in API GET /test text [id]. comment", apiChange.LocalizedError(checker.NewDefaultLocalizer())) | ||
require.Equal(t, "error at source, in API GET /test text [id]. comment", apiChange.Error()) | ||
} | ||
|
||
func TestApiChange_MatchIgnore(t *testing.T) { | ||
require.True(t, apiChange.MatchIgnore("/test", "error at source, in api get /test text [id]. comment")) | ||
} | ||
|
||
func TestApiChange_PrettyPiped(t *testing.T) { | ||
piped := true | ||
save := checker.SetPipedOutput(&piped) | ||
defer checker.SetPipedOutput(save) | ||
require.Equal(t, "error at source, in API GET /test text [id]. comment", apiChange.PrettyErrorText(checker.NewDefaultLocalizer())) | ||
} |
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,17 @@ | ||
//go:build unix | ||
|
||
package checker_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker" | ||
) | ||
|
||
func TestApiChange_PrettyNotPipedUnix(t *testing.T) { | ||
piped := false | ||
save := checker.SetPipedOutput(&piped) | ||
defer checker.SetPipedOutput(save) | ||
require.Equal(t, "\x1b[31merror\x1b[0m\t[\x1b[33mid\x1b[0m] at source\t\n\tin API \x1b[32mGET\x1b[0m \x1b[32m/test\x1b[0m\n\t\ttext\n\t\tcomment", apiChange.PrettyErrorText(checker.NewDefaultLocalizer())) | ||
} |
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,15 @@ | ||
package checker_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker" | ||
) | ||
|
||
func TestApiChange_PrettyNotPipedWindows(t *testing.T) { | ||
piped := false | ||
save := checker.SetPipedOutput(&piped) | ||
defer checker.SetPipedOutput(save) | ||
require.Equal(t, "error\t[id] at source\t\n\tin API GET /test\n\t\ttext\n\t\tcomment", apiChange.PrettyErrorText(checker.NewDefaultLocalizer())) | ||
} |
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
Oops, something went wrong.