mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli/support): confirm before creating bundle (#12684)
Forces user to confirm before creating a support bundle. Also adds contextual information to the bundle under cli_logs.txt.
This commit is contained in:
+7
-4
@@ -76,7 +76,7 @@ func TestSupportBundle(t *testing.T) {
|
||||
|
||||
d := t.TempDir()
|
||||
path := filepath.Join(d, "bundle.zip")
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--output", path)
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--output-file", path, "--yes")
|
||||
//nolint: gocritic // requires owner privilege
|
||||
clitest.SetupConfig(t, client, root)
|
||||
err = inv.Run()
|
||||
@@ -88,7 +88,7 @@ func TestSupportBundle(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t, nil)
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
inv, root := clitest.New(t, "support", "bundle")
|
||||
inv, root := clitest.New(t, "support", "bundle", "--yes")
|
||||
//nolint: gocritic // requires owner privilege
|
||||
clitest.SetupConfig(t, client, root)
|
||||
err := inv.Run()
|
||||
@@ -103,7 +103,7 @@ func TestSupportBundle(t *testing.T) {
|
||||
OrganizationID: admin.OrganizationID,
|
||||
OwnerID: admin.UserID,
|
||||
}).Do() // without agent!
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name)
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--yes")
|
||||
//nolint: gocritic // requires owner privilege
|
||||
clitest.SetupConfig(t, client, root)
|
||||
err := inv.Run()
|
||||
@@ -119,7 +119,7 @@ func TestSupportBundle(t *testing.T) {
|
||||
OrganizationID: user.OrganizationID,
|
||||
OwnerID: member.ID,
|
||||
}).WithAgent().Do()
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name)
|
||||
inv, root := clitest.New(t, "support", "bundle", r.Workspace.Name, "--yes")
|
||||
clitest.SetupConfig(t, memberClient, root)
|
||||
err := inv.Run()
|
||||
require.ErrorContains(t, err, "failed authorization check")
|
||||
@@ -219,6 +219,9 @@ func assertBundleContents(t *testing.T, path string) {
|
||||
case "logs.txt":
|
||||
bs := readBytesFromZip(t, f)
|
||||
require.NotEmpty(t, bs, "logs should not be empty")
|
||||
case "cli_logs.txt":
|
||||
bs := readBytesFromZip(t, f)
|
||||
require.NotEmpty(t, bs, "CLI logs should not be empty")
|
||||
default:
|
||||
require.Failf(t, "unexpected file in bundle", f.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user