Refactor TestDefaultVariables test

Use a map[string]struct for the `TestDefaultVariables` test to be a
consistent with our new table tests.

Rename the variable `test` to `c` since test is the name of the package
and can be confusing.

This is a small follow up from gitlab-org/gitlab-runner!1267
parent cec3ec4e
Pipeline #55885503 passed with stages
in 91 minutes and 14 seconds
......@@ -1276,29 +1276,25 @@ func TestGitCleanFlags(t *testing.T) {
func TestDefaultVariables(t *testing.T) {
tests := []struct {
name string
tests := map[string]struct {
jobVariables JobVariables
rootDir string
key string
expectedValue string
name: "get default CI_SERVER value",
"get default CI_SERVER value": {
jobVariables: JobVariables{},
rootDir: "/builds",
key: "CI_SERVER",
expectedValue: "yes",
name: "get default CI_PROJECT_DIR value",
"get default CI_PROJECT_DIR value": {
jobVariables: JobVariables{},
rootDir: "/builds",
expectedValue: "/builds/test-namespace/test-repo",
name: "get overwritten CI_PROJECT_DIR value",
"get overwritten CI_PROJECT_DIR value": {
jobVariables: JobVariables{
{Key: "GIT_CLONE_PATH", Value: "/builds/go/src/", Public: true},
......@@ -1308,8 +1304,8 @@ func TestDefaultVariables(t *testing.T) {
for _, test := range tests {
t.Run(, func(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
build := Build{
JobResponse: JobResponse{
GitInfo: GitInfo{
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment