Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix external check size to print warning message Signed-off-by: adripedriza <adripedriza@gmail.com> * set okteto cli for remote build dynamically Signed-off-by: adripedriza <adripedriza@gmail.com> * refactor regexp Signed-off-by: adripedriza <adripedriza@gmail.com> * add test Signed-off-by: adripedriza <adripedriza@gmail.com> --------- Signed-off-by: adripedriza <adripedriza@gmail.com> (cherry picked from commit 40ece09) Signed-off-by: adripedriza <adripedriza@gmail.com> Co-authored-by: adripedriza <adripedriza@gmail.com>
- Loading branch information
1 parent
42456b2
commit 680f05e
Showing
6 changed files
with
146 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package deploy | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/okteto/okteto/pkg/constants" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_getOktetoCLIVersion(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
versionString, expected, cliImageEnv string | ||
}{ | ||
{ | ||
name: "no version string and no env return latest", | ||
versionString: "", | ||
expected: "okteto/okteto:latest", | ||
}, | ||
{ | ||
name: "no version string return env value", | ||
versionString: "", | ||
cliImageEnv: "okteto/remote:test", | ||
expected: "okteto/remote:test", | ||
}, | ||
{ | ||
name: "found version string", | ||
versionString: "2.2.2", | ||
expected: "okteto/okteto:2.2.2", | ||
}, | ||
{ | ||
name: "found incorrect version string return latest ", | ||
versionString: "2.a.2", | ||
expected: "okteto/okteto:latest", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
if tt.cliImageEnv != "" { | ||
os.Setenv(constants.OKtetoDeployRemoteImage, tt.cliImageEnv) | ||
defer os.Unsetenv(constants.OKtetoDeployRemoteImage) | ||
} | ||
|
||
version := getOktetoCLIVersion(tt.versionString) | ||
require.Equal(t, version, tt.expected) | ||
}) | ||
} | ||
} |
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,51 @@ | ||
package destroy | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/okteto/okteto/pkg/constants" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_getOktetoCLIVersion(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
versionString, expected, cliImageEnv string | ||
}{ | ||
{ | ||
name: "no version string and no env return latest", | ||
versionString: "", | ||
expected: "okteto/okteto:latest", | ||
}, | ||
{ | ||
name: "no version string return env value", | ||
versionString: "", | ||
cliImageEnv: "okteto/remote:test", | ||
expected: "okteto/remote:test", | ||
}, | ||
{ | ||
name: "found version string", | ||
versionString: "2.2.2", | ||
expected: "okteto/okteto:2.2.2", | ||
}, | ||
{ | ||
name: "found incorrect version string return latest ", | ||
versionString: "2.a.2", | ||
expected: "okteto/okteto:latest", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
if tt.cliImageEnv != "" { | ||
os.Setenv(constants.OKtetoDeployRemoteImage, tt.cliImageEnv) | ||
defer os.Unsetenv(constants.OKtetoDeployRemoteImage) | ||
} | ||
|
||
version := getOktetoCLIVersion(tt.versionString) | ||
require.Equal(t, version, tt.expected) | ||
}) | ||
} | ||
} |
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