test: explicit define builder for e2e tests tied to golang as test remote repo, config and envs (#1081)

This commit is contained in:
Jefferson Ramos 2022-06-29 10:35:30 -03:00 committed by GitHub
parent 5f8c01829e
commit 81091863e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 2 deletions

View File

@ -15,7 +15,11 @@ import (
// Build runs `func build' command for a given test project.
func Build(t *testing.T, knFunc *TestShellCmdRunner, project *FunctionTestProject) {
result := knFunc.Exec("build", "--path", project.ProjectPath, "--registry", GetRegistry())
buildArgs := []string{"build", "--path", project.ProjectPath, "--registry", GetRegistry()}
if project.Builder != "" {
buildArgs = append(buildArgs, "--builder", project.Builder)
}
result := knFunc.Exec(buildArgs...)
if result.Error != nil {
t.Fail()
}

View File

@ -104,6 +104,7 @@ func TestConfigEnvs(t *testing.T) {
project.FunctionName = "test-config-envs"
project.ProjectPath = filepath.Join(os.TempDir(), project.FunctionName)
project.RemoteRepository = "http://github.com/boson-project/test-templates.git"
project.Builder = "pack"
Create(t, knFunc.TestShell, project)
defer func() { _ = project.RemoveProjectFolder() }()
@ -164,6 +165,7 @@ func TestConfigEnvs(t *testing.T) {
// Deploy
knFunc.TestShell.WithEnv(testEnvName, testEnvValue)
Build(t, knFunc.TestShell, &project)
Deploy(t, knFunc.TestShell, &project)
defer Delete(t, knFunc.TestShell, &project)
ReadyCheck(t, knFunc.TestShell, project)

View File

@ -57,6 +57,7 @@ func TestConfigLabel(t *testing.T) {
project.Template = "http"
project.FunctionName = "test-config-labels"
project.ProjectPath = filepath.Join(os.TempDir(), project.FunctionName)
project.Builder = "pack"
Create(t, knFunc.TestShell, project)
defer func() { _ = project.RemoveProjectFolder() }()
@ -75,6 +76,7 @@ func TestConfigLabel(t *testing.T) {
// Deploy
knFunc.TestShell.WithEnv(testEnvName, testEnvValue)
Build(t, knFunc.TestShell, &project)
Deploy(t, knFunc.TestShell, &project)
defer Delete(t, knFunc.TestShell, &project)

View File

@ -101,6 +101,7 @@ func TestConfigVolumes(t *testing.T) {
project.FunctionName = "test-config-volumes"
project.ProjectPath = filepath.Join(os.TempDir(), project.FunctionName)
project.RemoteRepository = "http://github.com/boson-project/test-templates.git"
project.Builder = "pack"
Create(t, knFunc.TestShell, project)
defer project.RemoveProjectFolder()
@ -139,6 +140,7 @@ func TestConfigVolumes(t *testing.T) {
configVolumesRemove("/bad-cm", enter)
// Deploy
Build(t, knFunc.TestShell, &project)
Deploy(t, knFunc.TestShell, &project)
defer Delete(t, knFunc.TestShell, &project)
ReadyCheck(t, knFunc.TestShell, project)

View File

@ -8,7 +8,7 @@ import (
// Intended to provide setup configuration for E2E tests
const (
defaultRegistry = "localhost:50000/user"
testTemplateRepository = "http://github.com/lance/test-templates.git" //nolint:varcheck,deadcode
testTemplateRepository = "http://github.com/boson-project/test-templates.git" //nolint:varcheck,deadcode
)
// GetRegistry returns registry

View File

@ -20,6 +20,7 @@ func TestRemoteRepository(t *testing.T) {
project.Template = "e2e"
project.FunctionName = "func-remote-repo"
project.ProjectPath = filepath.Join(os.TempDir(), project.FunctionName)
project.Builder = "pack"
result := knFunc.Exec("create", project.ProjectPath,
"--language", project.Runtime,

View File

@ -22,6 +22,8 @@ type FunctionTestProject struct {
Template string
// Git Location of a Remote Repository used to pull the template
RemoteRepository string
// Indicates which builder should be uses (i.e: pack|s2i)
Builder string
// Indicates function is already built
IsBuilt bool
// Indicates function is already deployed