Skip to content

Commit 7d21f4a

Browse files
authored
fix: env vars now reflect new plugin name (#56)
1 parent 1c75b98 commit 7d21f4a

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/plugin/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Config struct {
1313
type EnvironmentConfigFetcher struct {
1414
}
1515

16-
const pluginEnvironmentPrefix = "BUILDKITE_PLUGIN_ECS_TASK_RUNNER"
16+
const pluginEnvironmentPrefix = "BUILDKITE_PLUGIN_MIGRATIONS_RUNNER"
1717

1818
func (f EnvironmentConfigFetcher) Fetch(config *Config) error {
1919
return envconfig.Process(pluginEnvironmentPrefix, config)

src/plugin/config_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ func TestFailOnMissingRequiredEnvironment(t *testing.T) {
2323
{
2424
name: "all required parameters are unset",
2525
disabledEnvVars: []string{
26-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME",
27-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_COMMAND",
28-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_TIMEOUT",
26+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME",
27+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_COMMAND",
28+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_TIMEOUT",
2929
},
3030
enabledEnvVars: map[string]string{},
31-
expectedErr: "required key BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME missing value",
31+
expectedErr: "required key BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME missing value",
3232
},
3333
{
3434
name: "variable COMMAND set",
3535
disabledEnvVars: []string{
36-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME",
36+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME",
3737
},
3838
enabledEnvVars: map[string]string{
39-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_COMMAND": "bin/script",
39+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_COMMAND": "bin/script",
4040
},
41-
expectedErr: "required key BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME missing value",
41+
expectedErr: "required key BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME missing value",
4242
},
4343
}
4444

@@ -72,10 +72,10 @@ func TestSucceedOnMissingOptionalEnvironment(t *testing.T) {
7272
{
7373
name: "variable COMMAND unset",
7474
disabledEnvVars: []string{
75-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_COMMAND",
75+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_COMMAND",
7676
},
7777
enabledEnvVars: map[string]string{
78-
"BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME": "test-parameter",
78+
"BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME": "test-parameter",
7979
},
8080
},
8181
}
@@ -99,16 +99,16 @@ func TestSucceedOnMissingOptionalEnvironment(t *testing.T) {
9999
}
100100

101101
func TestFetchConfigFromEnvironment(t *testing.T) {
102-
unsetEnv(t, "BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME")
103-
unsetEnv(t, "BUILDKITE_PLUGIN_ECS_TASK_RUNNER_COMMAND")
104-
unsetEnv(t, "BUILDKITE_PLUGIN_ECS_TASK_RUNNER_TIME_OUT")
102+
unsetEnv(t, "BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME")
103+
unsetEnv(t, "BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_COMMAND")
104+
unsetEnv(t, "BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_TIME_OUT")
105105

106106
var config plugin.Config
107107
fetcher := plugin.EnvironmentConfigFetcher{}
108108

109-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME", "test-parameter")
110-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_COMMAND", "hello-world")
111-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_TIME_OUT", "600")
109+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME", "test-parameter")
110+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_COMMAND", "hello-world")
111+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_TIME_OUT", "600")
112112

113113
err := fetcher.Fetch(&config)
114114

@@ -118,7 +118,7 @@ func TestFetchConfigFromEnvironment(t *testing.T) {
118118
assert.Equal(t, 600, config.TimeOut, "fetched timeout should match environment")
119119

120120
// test default value
121-
unsetEnv(t, "BUILDKITE_PLUGIN_ECS_TASK_RUNNER_TIME_OUT")
121+
unsetEnv(t, "BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_TIME_OUT")
122122
err = fetcher.Fetch(&config)
123123
require.NoError(t, err, "fetch should not error")
124124
assert.Equal(t, 2700, config.TimeOut, "fetched timeout should match environment")

src/plugin/task-runner_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ func (m MockBuildKiteAgent) Annotate(ctx context.Context, message string, style
2121

2222
func TestRunPluginResponse(t *testing.T) {
2323
buildKiteAgent := MockBuildKiteAgent{}
24-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_PARAMETER_NAME", "test-parameter")
25-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_SCRIPT", "hello-world")
26-
t.Setenv("BUILDKITE_PLUGIN_ECS_TASK_RUNNER_TIME_OUT", "15")
24+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_PARAMETER_NAME", "test-parameter")
25+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_SCRIPT", "hello-world")
26+
t.Setenv("BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_TIME_OUT", "15")
2727
mockFetcher := plugin.EnvironmentConfigFetcher{}
2828
var config plugin.Config
2929
err := mockFetcher.Fetch(&config)

tests/download.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ load '../lib/download.bash'
1414

1515
#TODO: Update this to reflect what we need to test in the task runner code
1616
setup() {
17-
export BUILDKITE_PLUGIN_ECR_TASK_RUNNER_BUILDKITE_PLUGIN_MESSAGE=true
17+
export BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_BUILDKITE_PLUGIN_MESSAGE=true
1818
}
1919

2020
#TODO: Update this to reflect what we need to test in the task runner code
2121
teardown() {
22-
unset BUILDKITE_PLUGIN_ECR_TASK_RUNNER_BUILDKITE_PLUGIN_MESSAGE
22+
unset BUILDKITE_PLUGIN_MIGRATIONS_RUNNER_BUILDKITE_PLUGIN_MESSAGE
2323
rm ./migrations-runner-buildkite-plugin || true
2424
}
2525

0 commit comments

Comments
 (0)