diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/publish_tests.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index fafc018f9..23db5d7de 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -1,5 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::process::Command; + use deno_core::serde_json::json; use test_util::assert_contains; use test_util::assert_not_contains; @@ -427,3 +429,44 @@ fn publish_context_builder() -> TestContextBuilder { .envs(env_vars_for_jsr_tests()) .use_temp_cwd() } + +#[test] +fn allow_dirty() { + let context = publish_context_builder().build(); + let temp_dir = context.temp_dir().path(); + temp_dir.join("deno.json").write_json(&json!({ + "name": "@foo/bar", + "version": "1.0.0", + "exports": "./main.ts", + })); + + temp_dir.join("main.ts").write(""); + + let cmd = Command::new("git") + .arg("init") + .arg(temp_dir.as_path()) + .output() + .unwrap(); + assert!(cmd.status.success()); + + let output = context + .new_command() + .arg("publish") + .arg("--token") + .arg("sadfasdf") + .run(); + output.assert_exit_code(1); + let output = output.combined_output(); + assert_contains!(output, "Aborting due to uncomitted changes"); + + let output = context + .new_command() + .arg("publish") + .arg("--allow-dirty") + .arg("--token") + .arg("sadfasdf") + .run(); + output.assert_exit_code(0); + let output = output.combined_output(); + assert_contains!(output, "Successfully published"); +} |