Fix output-related tests (#4288)
* Fix command tests * More test fixes * Use backticks to escape quoted strings * More test fixes * Fix mismatched error output failures * Fix mismatched error output failures
This commit is contained in:
parent
f039404a8a
commit
fb81016252
|
@ -171,7 +171,7 @@ func ParseSSHHelperConfig(contents string) (*SSHHelperConfig, error) {
|
|||
}
|
||||
|
||||
if c.VaultAddr == "" {
|
||||
return nil, fmt.Errorf("missing config 'vault_addr'")
|
||||
return nil, fmt.Errorf(`missing config "vault_addr"`)
|
||||
}
|
||||
return &c, nil
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestParseSSHHelperConfig_missingVaultAddr(t *testing.T) {
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "ssh_helper: missing config 'vault_addr'") {
|
||||
if !strings.Contains(err.Error(), `missing config "vault_addr"`) {
|
||||
t.Errorf("bad error: %s", err)
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ nope = "bad"
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "ssh_helper: invalid key 'nope' on line 3") {
|
||||
if !strings.Contains(err.Error(), `ssh_helper: invalid key "nope" on line 3`) {
|
||||
t.Errorf("bad error: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ nope = "true"
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'nope' on line 3") {
|
||||
if !strings.Contains(err.Error(), `invalid key "nope" on line 3`) {
|
||||
t.Errorf("bad error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ nope = "true"
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'nope' on line 3") {
|
||||
if !strings.Contains(err.Error(), `invalid key "nope" on line 3`) {
|
||||
t.Errorf("bad error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ path "secret" {
|
|||
}
|
||||
|
||||
stderr := ui.ErrorWriter.String()
|
||||
expected := "Failed to parse policy"
|
||||
expected := "failed to parse policy"
|
||||
if !strings.Contains(stderr, expected) {
|
||||
t.Errorf("expected %q to include %q", stderr, expected)
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ path "secret" {
|
|||
}
|
||||
|
||||
stderr := ui.ErrorWriter.String()
|
||||
expected := "Failed to parse policy"
|
||||
expected := "failed to parse policy"
|
||||
if !strings.Contains(stderr, expected) {
|
||||
t.Errorf("expected %q to include %q", stderr, expected)
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ path "secret" {
|
|||
}
|
||||
|
||||
stderr := ui.ErrorWriter.String()
|
||||
expected := "Failed to parse policy"
|
||||
expected := "failed to parse policy"
|
||||
if !strings.Contains(stderr, expected) {
|
||||
t.Errorf("expected %q to include %q", stderr, expected)
|
||||
}
|
||||
|
|
|
@ -395,11 +395,11 @@ nope = "yes"
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'bad' on line 2") {
|
||||
if !strings.Contains(err.Error(), `invalid key "bad" on line 2`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'nope' on line 3") {
|
||||
if !strings.Contains(err.Error(), `invalid key "nope" on line 3`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
}
|
||||
|
@ -419,11 +419,11 @@ listener "tcp" {
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "listeners.tcp: invalid key 'bad' on line 3") {
|
||||
if !strings.Contains(err.Error(), `listeners.tcp: invalid key "bad" on line 3`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "listeners.tcp: invalid key 'nope' on line 4") {
|
||||
if !strings.Contains(err.Error(), `listeners.tcp: invalid key "nope" on line 4`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
}
|
||||
|
@ -443,11 +443,11 @@ telemetry {
|
|||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "telemetry: invalid key 'bad' on line 3") {
|
||||
if !strings.Contains(err.Error(), `telemetry: invalid key "bad" on line 3`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "telemetry: invalid key 'nope' on line 4") {
|
||||
if !strings.Contains(err.Error(), `telemetry: invalid key "nope" on line 4`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ func TestSystemBackend_mount_invalid(t *testing.T) {
|
|||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "unknown backend type: nope" {
|
||||
if resp.Data["error"] != `unknown backend type: "nope"` {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ func TestSystemBackend_remount_invalid(t *testing.T) {
|
|||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "no matching mount at 'unknown/'" {
|
||||
if resp.Data["error"] != `no matching mount at "unknown/"` {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ func TestSystemBackend_remount_system(t *testing.T) {
|
|||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "cannot remount 'sys/'" {
|
||||
if resp.Data["error"] != `cannot remount "sys/"` {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
@ -1493,7 +1493,7 @@ func TestSystemBackend_enableAuth_invalid(t *testing.T) {
|
|||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "unknown backend type: nope" {
|
||||
if resp.Data["error"] != `unknown backend type: "nope"` {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
@ -1710,7 +1710,7 @@ func TestSystemBackend_enableAudit_invalid(t *testing.T) {
|
|||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "unknown backend type: nope" {
|
||||
if resp.Data["error"] != `unknown backend type: "nope"` {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ func TestCore_Remount_Cleanup(t *testing.T) {
|
|||
func TestCore_Remount_Protected(t *testing.T) {
|
||||
c, _, _ := TestCoreUnsealed(t)
|
||||
err := c.remount(context.Background(), "sys", "foo")
|
||||
if err.Error() != "cannot remount 'sys/'" {
|
||||
if err.Error() != `cannot remount "sys/"` {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ func TestPolicyStore_Root(t *testing.T) {
|
|||
|
||||
// Set should fail
|
||||
err = ps.SetPolicy(context.Background(), p)
|
||||
if err.Error() != "cannot update root policy" {
|
||||
if err.Error() != `cannot update "root" policy` {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
// Delete should fail
|
||||
err = ps.DeletePolicy(context.Background(), "root", PolicyTypeACL)
|
||||
if err.Error() != "cannot delete root policy" {
|
||||
if err.Error() != `cannot delete "root" policy` {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,11 +259,11 @@ nope = "yes"
|
|||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'bad' on line 2") {
|
||||
if !strings.Contains(err.Error(), `invalid key "bad" on line 2`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'nope' on line 3") {
|
||||
if !strings.Contains(err.Error(), `invalid key "nope" on line 3`) {
|
||||
t.Errorf("bad error: %q", err)
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ path "/" {
|
|||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "invalid key 'capabilites' on line 3") {
|
||||
if !strings.Contains(err.Error(), `invalid key "capabilites" on line 3`) {
|
||||
t.Errorf("bad error: %s", err)
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ path "/" {
|
|||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), `path "/": invalid policy 'banana'`) {
|
||||
if !strings.Contains(err.Error(), `path "/": invalid policy "banana"`) {
|
||||
t.Errorf("bad error: %s", err)
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ path "/" {
|
|||
t.Fatalf("expected error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), `path "/": invalid capability 'banana'`) {
|
||||
if !strings.Contains(err.Error(), `path "/": invalid capability "banana"`) {
|
||||
t.Errorf("bad error: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue