agent: Fix wrong content-type flag name. (#2131)
Co-authored-by: Yun Peng <pcloudy@google.com>
diff --git a/agent/src/artifact/upload.rs b/agent/src/artifact/upload.rs
index 927ba86..e968e42 100644
--- a/agent/src/artifact/upload.rs
+++ b/agent/src/artifact/upload.rs
@@ -419,11 +419,9 @@
) -> Result<()> {
let artifact = artifact.display().to_string();
let mut args = vec!["artifact", "upload"];
- let ct_arg = content_type
- .map(|ct| "--content_type=".to_owned() + ct)
- .unwrap_or_default();
- if !ct_arg.is_empty() {
- args.push(ct_arg.as_str());
+ if let Some(content_type) = content_type {
+ args.push("--content-type");
+ args.push(content_type);
}
args.push(artifact.as_str());
execute_command(dry, cwd, "buildkite-agent", &args)
diff --git a/agent/tests/artifact/upload.rs b/agent/tests/artifact/upload.rs
index 8a892c8..6d210c5 100644
--- a/agent/tests/artifact/upload.rs
+++ b/agent/tests/artifact/upload.rs
@@ -19,7 +19,7 @@
]);
cmd.assert()
.success()
- .stdout(predicates::ord::eq("buildkite-agent artifact upload --content_type=text/plain;encoding=utf-8 src\\test\\shell\\bazel\\resource_compiler_toolchain_test\\test.log\n"));
+ .stdout(predicates::ord::eq("buildkite-agent artifact upload --content-type text/plain;encoding=utf-8 src\\test\\shell\\bazel\\resource_compiler_toolchain_test\\test.log\n"));
Ok(())
}
@@ -37,7 +37,7 @@
]);
cmd.assert()
.success()
- .stdout(predicates::ord::eq("buildkite-agent artifact upload --content_type=text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log\n"));
+ .stdout(predicates::ord::eq("buildkite-agent artifact upload --content-type text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log\n"));
Ok(())
}
@@ -139,7 +139,7 @@
]);
cmd.assert()
.success()
- .stdout(predicates::str::contains("buildkite-agent artifact upload --content_type=text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log").count(1));
+ .stdout(predicates::str::contains("buildkite-agent artifact upload --content-type text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log").count(1));
Ok(())
}
@@ -178,7 +178,7 @@
cmd.assert()
.success()
- .stdout(predicates::str::contains("buildkite-agent artifact upload --content_type=text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log"));
+ .stdout(predicates::str::contains("buildkite-agent artifact upload --content-type text/plain;encoding=utf-8 src/test/shell/bazel/starlark_repository_test/shard_4_of_6/test_attempts/attempt_1.log"));
Ok(())
})
}