-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #906 from aziontech/dev
Deploy to Production - 2024/07/22
- Loading branch information
Showing
16 changed files
with
1,868 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package dev | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/aziontech/azion-cli/pkg/cmdutil" | ||
"github.com/aziontech/azion-cli/pkg/httpmock" | ||
"github.com/aziontech/azion-cli/pkg/logger" | ||
"github.com/aziontech/azion-cli/pkg/testutils" | ||
vulcanPkg "github.com/aziontech/azion-cli/pkg/vulcan" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
func TestDev(t *testing.T) { | ||
logger.New(zapcore.DebugLevel) | ||
tests := []struct { | ||
name string | ||
mockVulcan func() *vulcanPkg.VulcanPkg | ||
mockCommandRun func(f *cmdutil.Factory, comm string) error | ||
isFirewall bool | ||
expectedError error | ||
}{ | ||
{ | ||
name: "dev - successful execution without firewall", | ||
mockVulcan: func() *vulcanPkg.VulcanPkg { | ||
return &vulcanPkg.VulcanPkg{ | ||
Command: func(flags, params string, f *cmdutil.Factory) string { | ||
return "echo 1" | ||
}, | ||
} | ||
}, | ||
mockCommandRun: func(f *cmdutil.Factory, comm string) error { | ||
return nil | ||
}, | ||
isFirewall: false, | ||
expectedError: nil, | ||
}, | ||
{ | ||
name: "dev - successful execution with firewall", | ||
mockVulcan: func() *vulcanPkg.VulcanPkg { | ||
return &vulcanPkg.VulcanPkg{ | ||
Command: func(flags, params string, f *cmdutil.Factory) string { | ||
return "echo 1" | ||
}, | ||
} | ||
}, | ||
mockCommandRun: func(f *cmdutil.Factory, comm string) error { | ||
return nil | ||
}, | ||
isFirewall: true, | ||
expectedError: nil, | ||
}, | ||
{ | ||
name: "dev - failed command execution", | ||
mockVulcan: func() *vulcanPkg.VulcanPkg { | ||
return &vulcanPkg.VulcanPkg{ | ||
Command: func(flags, params string, f *cmdutil.Factory) string { | ||
return "echo 1" | ||
}, | ||
} | ||
}, | ||
mockCommandRun: func(f *cmdutil.Factory, comm string) error { | ||
return errors.New("failed to run command") | ||
}, | ||
isFirewall: false, | ||
expectedError: errors.New("Error executing Vulcan: Failed to run dev command. Verify if the command is correct and check the output above for more details. Run the 'azion dev' command again or contact Azion's support"), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
mock := &httpmock.Registry{} | ||
f, _, _ := testutils.NewFactory(mock) | ||
|
||
devCmd := NewDevCmd(f) | ||
devCmd.Vulcan = tt.mockVulcan | ||
devCmd.CommandRunInteractive = tt.mockCommandRun | ||
|
||
isFirewall = tt.isFirewall | ||
|
||
err := devCmd.Run(f) | ||
if tt.expectedError != nil { | ||
require.Error(t, err) | ||
assert.Equal(t, tt.expectedError.Error(), err.Error()) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.