Skip to content

Commit

Permalink
Fix sidecar env tests (hashicorp#219)
Browse files Browse the repository at this point in the history
* Fix sidecar env tests

* make fmt
  • Loading branch information
jasonodonnell authored Feb 2, 2021
1 parent 4fdf3d0 commit 72299ee
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions agent-inject/agent/container_sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestContainerSidecar(t *testing.T) {
t.Errorf("creating container sidecar failed, it shouldn't have: %s", err)
}

expectedEnvs := 2
expectedEnvs := 3
if len(container.Env) != expectedEnvs {
t.Errorf("wrong number of env vars, got %d, should have been %d", len(container.Env), expectedEnvs)
}
Expand All @@ -128,14 +128,22 @@ func TestContainerSidecar(t *testing.T) {
t.Error("env value empty, it shouldn't be")
}

if container.Env[1].Name != "VAULT_CONFIG" {
t.Errorf("env name wrong, should have been %s, got %s", "VAULT_CONFIG", container.Env[1].Name)
if container.Env[1].Name != "VAULT_LOG_FORMAT" {
t.Errorf("env name wrong, should have been %s, got %s", "VAULT_LOG_FORMAT", container.Env[1].Name)
}

if container.Env[1].Value == "" {
t.Error("env value empty, it shouldn't be")
}

if container.Env[2].Name != "VAULT_CONFIG" {
t.Errorf("env name wrong, should have been %s, got %s", "VAULT_CONFIG", container.Env[2].Name)
}

if container.Env[2].Value == "" {
t.Error("env value empty, it shouldn't be")
}

if len(container.Args) != 1 {
t.Errorf("wrong number of args, got %d, should have been %d", len(container.Args), 1)
}
Expand Down Expand Up @@ -265,7 +273,7 @@ func TestContainerSidecarConfigMap(t *testing.T) {
t.Errorf("creating container sidecar failed, it shouldn't have: %s", err)
}

expectedEnvs := 1
expectedEnvs := 2
if len(container.Env) != expectedEnvs {
t.Errorf("wrong number of env vars, got %d, should have been %d", len(container.Env), expectedEnvs)
}
Expand Down

0 comments on commit 72299ee

Please sign in to comment.