mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 23:59:53 +00:00
Merge pull request #1470 from openziti/fix.os.specific.file.not.found.checks
fixes tests that would check for OS specific error messages
This commit is contained in:
@@ -3,10 +3,12 @@ package create
|
||||
import (
|
||||
"fmt"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -111,15 +113,15 @@ func init() {
|
||||
}
|
||||
|
||||
func TestControllerOutputPathDoesNotExist(t *testing.T) {
|
||||
expectedErrorMsg := "stat /IDoNotExist: no such file or directory"
|
||||
|
||||
// Create the options with non-existent path
|
||||
options := &CreateConfigControllerOptions{}
|
||||
options.Output = "/IDoNotExist/MyController.yaml"
|
||||
|
||||
err := options.run(&ConfigTemplateValues{})
|
||||
|
||||
assert.EqualError(t, err, expectedErrorMsg, "Error does not match, expected %s but got %s", expectedErrorMsg, err)
|
||||
//check wrapped error type and not internal strings as they vary between operating systems
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, errors.Unwrap(err), syscall.ENOENT)
|
||||
}
|
||||
|
||||
func TestCreateConfigControllerTemplateValues(t *testing.T) {
|
||||
|
||||
@@ -2,11 +2,13 @@ package create
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/constants"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -215,8 +217,6 @@ func TestEdgeRouterCannotBeWSSAndPrivate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEdgeRouterOutputPathDoesNotExist(t *testing.T) {
|
||||
expectedErrorMsg := "stat /IDoNotExist: no such file or directory"
|
||||
|
||||
// Set the router options
|
||||
routerOptions := clearEnvAndInitializeTestData()
|
||||
routerOptions.TunnelerMode = defaultTunnelerMode
|
||||
@@ -225,7 +225,8 @@ func TestEdgeRouterOutputPathDoesNotExist(t *testing.T) {
|
||||
|
||||
err := routerOptions.runEdgeRouter(&ConfigTemplateValues{})
|
||||
|
||||
assert.EqualError(t, err, expectedErrorMsg, "Error does not match, expected %s but got %s", expectedErrorMsg, err)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, errors.Unwrap(err), syscall.ENOENT)
|
||||
}
|
||||
|
||||
func TestExecuteCreateConfigRouterEdgeHasNonBlankTemplateValues(t *testing.T) {
|
||||
|
||||
@@ -2,10 +2,12 @@ package create
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/constants"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -94,7 +96,6 @@ func TestBlankFabricRouterNameBecomesHostname(t *testing.T) {
|
||||
|
||||
func TestFabricRouterOutputPathDoesNotExist(t *testing.T) {
|
||||
routerOptions := clearEnvAndInitializeTestData()
|
||||
expectedErrorMsg := "stat /IDoNotExist: no such file or directory"
|
||||
|
||||
// Set the router options
|
||||
clearEnvAndInitializeTestData()
|
||||
@@ -103,7 +104,8 @@ func TestFabricRouterOutputPathDoesNotExist(t *testing.T) {
|
||||
|
||||
err := routerOptions.runFabricRouter(&ConfigTemplateValues{})
|
||||
|
||||
assert.EqualError(t, err, expectedErrorMsg, "Error does not match, expected %s but got %s", expectedErrorMsg, err)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, errors.Unwrap(err), syscall.ENOENT)
|
||||
}
|
||||
|
||||
func TestDefaultZitiFabricRouterListenerBindPort(t *testing.T) {
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
|
||||
func HomeDir() string {
|
||||
if h := os.Getenv("HOME"); h != "" {
|
||||
return h
|
||||
return NormalizePath(h)
|
||||
}
|
||||
h := os.Getenv("USERPROFILE") // windows
|
||||
if h == "" {
|
||||
|
||||
Reference in New Issue
Block a user