2022-02-12 19:34:04 +00:00
|
|
|
package cli_test
|
|
|
|
|
|
|
|
import (
|
2023-01-16 20:32:11 +00:00
|
|
|
"bytes"
|
2022-05-20 15:29:10 +00:00
|
|
|
"os"
|
2022-02-12 19:34:04 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/coder/coder/cli/clitest"
|
|
|
|
"github.com/coder/coder/coderd/coderdtest"
|
2022-03-25 21:07:45 +00:00
|
|
|
"github.com/coder/coder/coderd/database"
|
2022-02-12 19:34:04 +00:00
|
|
|
"github.com/coder/coder/provisioner/echo"
|
2022-05-20 15:29:10 +00:00
|
|
|
"github.com/coder/coder/provisionersdk/proto"
|
2022-02-17 16:44:49 +00:00
|
|
|
"github.com/coder/coder/pty/ptytest"
|
2022-02-12 19:34:04 +00:00
|
|
|
)
|
|
|
|
|
2022-06-16 18:36:11 +00:00
|
|
|
var provisionCompleteWithAgent = []*proto.Provision_Response{
|
|
|
|
{
|
|
|
|
Type: &proto.Provision_Response_Complete{
|
|
|
|
Complete: &proto.Provision_Complete{
|
|
|
|
Resources: []*proto.Resource{
|
|
|
|
{
|
|
|
|
Type: "compute",
|
|
|
|
Name: "main",
|
|
|
|
Agents: []*proto.Agent{
|
|
|
|
{
|
|
|
|
Name: "smith",
|
|
|
|
OperatingSystem: "linux",
|
|
|
|
Architecture: "i386",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:42:40 +00:00
|
|
|
func TestTemplateCreate(t *testing.T) {
|
2022-02-12 19:34:04 +00:00
|
|
|
t.Parallel()
|
2022-03-22 19:17:50 +00:00
|
|
|
t.Run("Create", func(t *testing.T) {
|
2022-02-12 19:34:04 +00:00
|
|
|
t.Parallel()
|
2022-09-04 16:28:09 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-03-07 17:40:54 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
2022-04-06 17:42:40 +00:00
|
|
|
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
|
2022-11-11 22:45:58 +00:00
|
|
|
Parse: echo.ParseComplete,
|
|
|
|
ProvisionApply: provisionCompleteWithAgent,
|
2022-02-12 19:34:04 +00:00
|
|
|
})
|
2022-06-07 12:37:45 +00:00
|
|
|
args := []string{
|
|
|
|
"templates",
|
|
|
|
"create",
|
|
|
|
"my-template",
|
|
|
|
"--directory", source,
|
|
|
|
"--test.provisioner", string(database.ProvisionerTypeEcho),
|
2022-11-09 19:36:25 +00:00
|
|
|
"--default-ttl", "24h",
|
2022-06-07 12:37:45 +00:00
|
|
|
}
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, args...)
|
2022-02-12 19:34:04 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2022-05-12 11:54:58 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2022-05-12 11:54:58 +00:00
|
|
|
|
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
2023-01-16 20:32:11 +00:00
|
|
|
{match: "Upload", write: "yes"},
|
2022-06-16 18:36:11 +00:00
|
|
|
{match: "compute.main"},
|
|
|
|
{match: "smith (linux, i386)"},
|
2022-05-12 11:54:58 +00:00
|
|
|
{match: "Confirm create?", write: "yes"},
|
2022-02-12 19:34:04 +00:00
|
|
|
}
|
2022-05-12 11:54:58 +00:00
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
2022-06-16 18:36:11 +00:00
|
|
|
if len(m.write) > 0 {
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
2022-02-12 19:34:04 +00:00
|
|
|
}
|
|
|
|
})
|
2022-05-20 15:29:10 +00:00
|
|
|
|
2023-01-16 20:32:11 +00:00
|
|
|
t.Run("CreateStdin", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
source, err := echo.Tar(&echo.Responses{
|
|
|
|
Parse: echo.ParseComplete,
|
|
|
|
ProvisionApply: provisionCompleteWithAgent,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
args := []string{
|
|
|
|
"templates",
|
|
|
|
"create",
|
|
|
|
"my-template",
|
|
|
|
"--directory", "-",
|
|
|
|
"--test.provisioner", string(database.ProvisionerTypeEcho),
|
|
|
|
"--default-ttl", "24h",
|
|
|
|
}
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, args...)
|
2023-01-16 20:32:11 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
|
|
|
pty := ptytest.New(t)
|
2023-03-23 22:42:20 +00:00
|
|
|
inv.Stdin = bytes.NewReader(source)
|
|
|
|
inv.Stdout = pty.Output()
|
2023-01-16 20:32:11 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
require.NoError(t, inv.Run())
|
2023-01-16 20:32:11 +00:00
|
|
|
})
|
|
|
|
|
2022-05-20 15:29:10 +00:00
|
|
|
t.Run("WithParameter", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2022-09-04 16:28:09 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-05-20 15:29:10 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
|
2022-11-11 22:45:58 +00:00
|
|
|
Parse: createTestParseResponse(),
|
|
|
|
ProvisionApply: echo.ProvisionComplete,
|
|
|
|
ProvisionPlan: echo.ProvisionComplete,
|
2022-05-20 15:29:10 +00:00
|
|
|
})
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho))
|
2022-05-20 15:29:10 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
2023-01-16 20:32:11 +00:00
|
|
|
{match: "Upload", write: "yes"},
|
2022-05-20 15:29:10 +00:00
|
|
|
{match: "Enter a value:", write: "bananas"},
|
|
|
|
{match: "Confirm create?", write: "yes"},
|
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("WithParameterFileContainingTheValue", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2022-09-04 16:28:09 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-05-20 15:29:10 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
|
2022-11-11 22:45:58 +00:00
|
|
|
Parse: createTestParseResponse(),
|
|
|
|
ProvisionApply: echo.ProvisionComplete,
|
|
|
|
ProvisionPlan: echo.ProvisionComplete,
|
2022-05-20 15:29:10 +00:00
|
|
|
})
|
|
|
|
tempDir := t.TempDir()
|
2022-07-22 12:14:45 +00:00
|
|
|
removeTmpDirUntilSuccessAfterTest(t, tempDir)
|
2022-05-20 15:29:10 +00:00
|
|
|
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
|
|
|
|
_, _ = parameterFile.WriteString("region: \"bananas\"")
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--parameter-file", parameterFile.Name())
|
2022-05-20 15:29:10 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
|
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
2023-01-16 20:32:11 +00:00
|
|
|
{match: "Upload", write: "yes"},
|
2022-05-20 15:29:10 +00:00
|
|
|
{match: "Confirm create?", write: "yes"},
|
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("WithParameterFileNotContainingTheValue", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2022-09-04 16:28:09 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-05-20 15:29:10 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
|
2022-11-11 22:45:58 +00:00
|
|
|
Parse: createTestParseResponse(),
|
|
|
|
ProvisionApply: echo.ProvisionComplete,
|
|
|
|
ProvisionPlan: echo.ProvisionComplete,
|
2022-05-20 15:29:10 +00:00
|
|
|
})
|
|
|
|
tempDir := t.TempDir()
|
2022-07-22 12:14:45 +00:00
|
|
|
removeTmpDirUntilSuccessAfterTest(t, tempDir)
|
2022-05-20 15:29:10 +00:00
|
|
|
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
|
|
|
|
_, _ = parameterFile.WriteString("zone: \"bananas\"")
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--parameter-file", parameterFile.Name())
|
2022-05-20 15:29:10 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2022-05-20 15:29:10 +00:00
|
|
|
|
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
2022-12-14 01:58:57 +00:00
|
|
|
{
|
2023-01-16 20:32:11 +00:00
|
|
|
match: "Upload",
|
2022-12-14 01:58:57 +00:00
|
|
|
write: "yes",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
match: "Enter a value:",
|
|
|
|
write: "bingo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
match: "Confirm create?",
|
|
|
|
write: "yes",
|
|
|
|
},
|
2022-05-20 15:29:10 +00:00
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
})
|
2022-06-17 19:18:07 +00:00
|
|
|
|
|
|
|
t.Run("Recreate template with same name (create, delete, create)", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2022-09-04 16:28:09 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-06-17 19:18:07 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
|
|
|
|
create := func() error {
|
|
|
|
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
|
2022-11-11 22:45:58 +00:00
|
|
|
Parse: echo.ParseComplete,
|
|
|
|
ProvisionApply: provisionCompleteWithAgent,
|
2022-06-17 19:18:07 +00:00
|
|
|
})
|
|
|
|
args := []string{
|
|
|
|
"templates",
|
|
|
|
"create",
|
|
|
|
"my-template",
|
|
|
|
"--yes",
|
|
|
|
"--directory", source,
|
|
|
|
"--test.provisioner", string(database.ProvisionerTypeEcho),
|
|
|
|
}
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, args...)
|
2022-06-17 19:18:07 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
return inv.Run()
|
2022-06-17 19:18:07 +00:00
|
|
|
}
|
|
|
|
del := func() error {
|
|
|
|
args := []string{
|
|
|
|
"templates",
|
|
|
|
"delete",
|
|
|
|
"my-template",
|
2022-07-11 18:13:56 +00:00
|
|
|
"--yes",
|
2022-06-17 19:18:07 +00:00
|
|
|
}
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, args...)
|
2022-06-17 19:18:07 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
return inv.Run()
|
2022-06-17 19:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err := create()
|
|
|
|
require.NoError(t, err, "Template must be created without error")
|
|
|
|
err = del()
|
|
|
|
require.NoError(t, err, "Template must be deleted without error")
|
|
|
|
err = create()
|
|
|
|
require.NoError(t, err, "Template must be recreated without error")
|
|
|
|
})
|
2022-09-07 20:01:18 +00:00
|
|
|
|
|
|
|
t.Run("WithParameterExceedingCharLimit", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2022-09-07 20:29:26 +00:00
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
2022-09-07 20:01:18 +00:00
|
|
|
coderdtest.CreateFirstUser(t, client)
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "1234567890123456789012345678901234567891", "--test.provisioner", string(database.ProvisionerTypeEcho))
|
2022-09-07 20:01:18 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.StartWithWaiter(t, inv).RequireContains("Template name must be less than 32 characters")
|
2022-09-07 20:01:18 +00:00
|
|
|
})
|
2023-02-17 08:07:45 +00:00
|
|
|
|
|
|
|
t.Run("WithVariablesFileWithoutRequiredValue", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
|
|
|
|
templateVariables := []*proto.TemplateVariable{
|
|
|
|
{
|
|
|
|
Name: "first_variable",
|
2023-03-23 22:42:20 +00:00
|
|
|
Description: "This is the first variable.",
|
2023-02-17 08:07:45 +00:00
|
|
|
Type: "string",
|
|
|
|
Required: true,
|
|
|
|
Sensitive: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "second_variable",
|
|
|
|
Description: "This is the first variable",
|
|
|
|
Type: "string",
|
|
|
|
DefaultValue: "abc",
|
|
|
|
Required: false,
|
|
|
|
Sensitive: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
source := clitest.CreateTemplateVersionSource(t,
|
|
|
|
createEchoResponsesWithTemplateVariables(templateVariables))
|
|
|
|
tempDir := t.TempDir()
|
|
|
|
removeTmpDirUntilSuccessAfterTest(t, tempDir)
|
|
|
|
variablesFile, _ := os.CreateTemp(tempDir, "variables*.yaml")
|
|
|
|
_, _ = variablesFile.WriteString(`second_variable: foobar`)
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--variables-file", variablesFile.Name())
|
2023-02-17 08:07:45 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
|
|
|
{match: "Upload", write: "yes"},
|
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
if len(m.write) > 0 {
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("WithVariablesFileWithTheRequiredValue", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
|
|
|
|
templateVariables := []*proto.TemplateVariable{
|
|
|
|
{
|
|
|
|
Name: "first_variable",
|
2023-03-23 22:42:20 +00:00
|
|
|
Description: "This is the first variable.",
|
2023-02-17 08:07:45 +00:00
|
|
|
Type: "string",
|
|
|
|
Required: true,
|
|
|
|
Sensitive: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "second_variable",
|
|
|
|
Description: "This is the second variable",
|
|
|
|
Type: "string",
|
|
|
|
DefaultValue: "abc",
|
|
|
|
Required: false,
|
|
|
|
Sensitive: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
source := clitest.CreateTemplateVersionSource(t,
|
|
|
|
createEchoResponsesWithTemplateVariables(templateVariables))
|
|
|
|
tempDir := t.TempDir()
|
|
|
|
removeTmpDirUntilSuccessAfterTest(t, tempDir)
|
|
|
|
variablesFile, _ := os.CreateTemp(tempDir, "variables*.yaml")
|
|
|
|
_, _ = variablesFile.WriteString(`first_variable: foobar`)
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--variables-file", variablesFile.Name())
|
2023-02-17 08:07:45 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
|
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
|
|
|
{match: "Upload", write: "yes"},
|
|
|
|
{match: "Confirm create?", write: "yes"},
|
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
if len(m.write) > 0 {
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("WithVariableOption", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
|
|
|
coderdtest.CreateFirstUser(t, client)
|
|
|
|
|
|
|
|
templateVariables := []*proto.TemplateVariable{
|
|
|
|
{
|
|
|
|
Name: "first_variable",
|
2023-03-23 22:42:20 +00:00
|
|
|
Description: "This is the first variable.",
|
2023-02-17 08:07:45 +00:00
|
|
|
Type: "string",
|
|
|
|
Required: true,
|
|
|
|
Sensitive: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
source := clitest.CreateTemplateVersionSource(t,
|
|
|
|
createEchoResponsesWithTemplateVariables(templateVariables))
|
2023-03-23 22:42:20 +00:00
|
|
|
inv, root := clitest.New(t, "templates", "create", "my-template", "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--variable", "first_variable=foobar")
|
2023-02-17 08:07:45 +00:00
|
|
|
clitest.SetupConfig(t, client, root)
|
2023-03-23 22:42:20 +00:00
|
|
|
pty := ptytest.New(t).Attach(inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
|
2023-03-23 22:42:20 +00:00
|
|
|
clitest.Start(t, inv)
|
2023-02-17 08:07:45 +00:00
|
|
|
|
|
|
|
matches := []struct {
|
|
|
|
match string
|
|
|
|
write string
|
|
|
|
}{
|
|
|
|
{match: "Upload", write: "yes"},
|
|
|
|
{match: "Confirm create?", write: "yes"},
|
|
|
|
}
|
|
|
|
for _, m := range matches {
|
|
|
|
pty.ExpectMatch(m.match)
|
|
|
|
pty.WriteLine(m.write)
|
|
|
|
}
|
|
|
|
})
|
2022-05-20 15:29:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func createTestParseResponse() []*proto.Parse_Response {
|
|
|
|
return []*proto.Parse_Response{{
|
|
|
|
Type: &proto.Parse_Response_Complete{
|
|
|
|
Complete: &proto.Parse_Complete{
|
|
|
|
ParameterSchemas: []*proto.ParameterSchema{{
|
|
|
|
AllowOverrideSource: true,
|
|
|
|
Name: "region",
|
|
|
|
Description: "description",
|
|
|
|
DefaultDestination: &proto.ParameterDestination{
|
|
|
|
Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
|
|
|
|
},
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need this for Windows because of a known issue with Go:
|
|
|
|
// https://github.com/golang/go/issues/52986
|
2022-07-22 12:14:45 +00:00
|
|
|
func removeTmpDirUntilSuccessAfterTest(t *testing.T, tempDir string) {
|
2022-05-20 15:29:10 +00:00
|
|
|
t.Helper()
|
|
|
|
t.Cleanup(func() {
|
|
|
|
err := os.RemoveAll(tempDir)
|
|
|
|
for err != nil {
|
|
|
|
err = os.RemoveAll(tempDir)
|
|
|
|
}
|
|
|
|
})
|
2022-02-12 19:34:04 +00:00
|
|
|
}
|