Skip to content

Commit

Permalink
separate windows and unix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Feb 28, 2024
1 parent ecf4660 commit f0ee26b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
19 changes: 0 additions & 19 deletions internal/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ func Test_Summary(t *testing.T) {
require.Contains(t, stdout.String(), `diff: true`)
}

func Test_InvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 102, internal.Run(cmdToArgs("oasdiff diff no-file ../data/openapi-test3.yaml"), io.Discard, &stderr))
require.Condition(t, func() (success bool) {
return stderr.String() == "Error: failed to load base spec from \"no-file\": open no-file: no such file or directory\n" ||
stderr.String() == "Error: failed to load base spec from \"no-file\": open no-file: The system cannot find the file specified.\n" // windows
}, stderr.String())
}

func Test_InvalidGlob(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 103, internal.Run(cmdToArgs(`oasdiff diff -c "a[" ../data/openapi-test3.yaml`), io.Discard, &stderr))
Expand Down Expand Up @@ -202,16 +193,6 @@ func Test_ComposedMode(t *testing.T) {
require.Equal(t, map[string]interface{}{"paths": map[string]interface{}{"deleted": []interface{}{"/api/old-test"}}}, bc)
}

func Test_ComposedModeInvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 103, internal.Run(cmdToArgs("oasdiff diff ../data/allof/* ../data/allof/* --composed --flatten"), io.Discard, &stderr))

require.Condition(t, func() (success bool) {
return stderr.String() == "Error: failed to load base specs from glob \"../data/allof/*\": failed to flatten allOf in \"../data/allof/invalid.yaml\": unable to resolve Type conflict: all Type values must be identical\n" ||
stderr.String() == "Error: failed to load base specs from glob \"../data/allof/*\": failed to flatten allOf in \"..\\data\\allof\\invalid.yaml\": unable to resolve Type conflict: all Type values must be identical" // windows
}, stderr.String())
}

func Test_Help(t *testing.T) {
var stdout bytes.Buffer
require.Zero(t, internal.Run(cmdToArgs("oasdiff --help"), &stdout, io.Discard))
Expand Down
22 changes: 22 additions & 0 deletions internal/run_unix_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package internal_test

import (
"bytes"
"io"
"testing"

"github.com/stretchr/testify/require"
"github.com/tufin/oasdiff/internal"
)

func Test_InvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 102, internal.Run(cmdToArgs("oasdiff diff no-file ../data/openapi-test3.yaml"), io.Discard, &stderr))
require.Equal(t, "Error: failed to load base spec from \"no-file\": open no-file: no such file or directory\n", stderr.String())
}

func Test_ComposedModeInvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 103, internal.Run(cmdToArgs("oasdiff diff ../data/allof/* ../data/allof/* --composed --flatten"), io.Discard, &stderr))
require.Equal(t, "Error: failed to load base specs from glob \"../data/allof/*\": failed to flatten allOf in \"../data/allof/invalid.yaml\": unable to resolve Type conflict: all Type values must be identical\n", stderr.String())
}
22 changes: 22 additions & 0 deletions internal/run_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package internal_test

import (
"bytes"
"io"
"testing"

"github.com/stretchr/testify/require"
"github.com/tufin/oasdiff/internal"
)

func Test_InvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 102, internal.Run(cmdToArgs("oasdiff diff no-file ../data/openapi-test3.yaml"), io.Discard, &stderr))
require.Equal(t, "Error: failed to load base spec from \"no-file\": open no-file: The system cannot find the file specified.\n", stderr.String())
}

func Test_ComposedModeInvalidFile(t *testing.T) {
var stderr bytes.Buffer
require.Equal(t, 103, internal.Run(cmdToArgs("oasdiff diff ../data/allof/* ../data/allof/* --composed --flatten"), io.Discard, &stderr))
require.Equal(t, "Error: failed to load base specs from glob \"../data/allof/*\": failed to flatten allOf in \"..\\data\\allof\\invalid.yaml\": unable to resolve Type conflict: all Type values must be identical\n", stderr.String())
}

0 comments on commit f0ee26b

Please sign in to comment.