diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/mod.rs | 3 | ||||
-rw-r--r-- | cli/tests/integration/publish_tests.rs | 38 | ||||
-rw-r--r-- | cli/tests/testdata/publish/missing_deno_json.out | 1 | ||||
-rw-r--r-- | cli/tests/testdata/publish/no_token.out | 1 | ||||
-rw-r--r-- | cli/tests/testdata/publish/successful.out | 3 | ||||
-rw-r--r-- | cli/tests/testdata/publish/successful/deno.json | 10 | ||||
-rw-r--r-- | cli/tests/testdata/publish/successful/mod.ts | 5 |
7 files changed, 61 insertions, 0 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs index 80b316432..5c9a00ff2 100644 --- a/cli/tests/integration/mod.rs +++ b/cli/tests/integration/mod.rs @@ -132,6 +132,9 @@ mod node_compat_tests; mod node_unit_tests; #[path = "npm_tests.rs"] mod npm; +#[path = "publish_tests.rs"] +mod publish; + #[path = "repl_tests.rs"] mod repl; #[path = "run_tests.rs"] diff --git a/cli/tests/integration/publish_tests.rs b/cli/tests/integration/publish_tests.rs new file mode 100644 index 000000000..6a40eabf6 --- /dev/null +++ b/cli/tests/integration/publish_tests.rs @@ -0,0 +1,38 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +static TEST_REGISTRY_URL: &str = "http://127.0.0.1:4250"; + +pub fn env_vars_for_registry() -> Vec<(String, String)> { + vec![ + ( + "DENO_REGISTRY_URL".to_string(), + TEST_REGISTRY_URL.to_string(), + ), + ( + "DENO_REGISTRY_API_URL".to_string(), + TEST_REGISTRY_URL.to_string(), + ), + ] +} + +itest!(no_token { + args: "do-not-use-publish publish/missing_deno_json", + output: "publish/no_token.out", + exit_code: 1, +}); + +itest!(missing_deno_json { + args: + "do-not-use-publish --token 'sadfasdf' $TESTDATA/publish/missing_deno_json", + output: "publish/missing_deno_json.out", + exit_code: 1, + temp_cwd: true, +}); + +itest!(successful { + args: "do-not-use-publish --token 'sadfasdf' $TESTDATA/publish/successful", + output: "publish/successful.out", + envs: env_vars_for_registry(), + http_server: true, + temp_cwd: true, +}); diff --git a/cli/tests/testdata/publish/missing_deno_json.out b/cli/tests/testdata/publish/missing_deno_json.out new file mode 100644 index 000000000..adaf33ea8 --- /dev/null +++ b/cli/tests/testdata/publish/missing_deno_json.out @@ -0,0 +1 @@ +error: Failed to read deno.json file at [WILDCARD]missing_deno_json[WILDCARD]
\ No newline at end of file diff --git a/cli/tests/testdata/publish/no_token.out b/cli/tests/testdata/publish/no_token.out new file mode 100644 index 000000000..41415094c --- /dev/null +++ b/cli/tests/testdata/publish/no_token.out @@ -0,0 +1 @@ +error: No means to authenticate. Pass a token to `--token`[WILDCARD] diff --git a/cli/tests/testdata/publish/successful.out b/cli/tests/testdata/publish/successful.out new file mode 100644 index 000000000..1049bbdb4 --- /dev/null +++ b/cli/tests/testdata/publish/successful.out @@ -0,0 +1,3 @@ +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +http://127.0.0.1:4250/@foo/bar/1.0.0_meta.json diff --git a/cli/tests/testdata/publish/successful/deno.json b/cli/tests/testdata/publish/successful/deno.json new file mode 100644 index 000000000..930f3aa08 --- /dev/null +++ b/cli/tests/testdata/publish/successful/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "jsr:@std/http@1" + } +} diff --git a/cli/tests/testdata/publish/successful/mod.ts b/cli/tests/testdata/publish/successful/mod.ts new file mode 100644 index 000000000..152bce40b --- /dev/null +++ b/cli/tests/testdata/publish/successful/mod.ts @@ -0,0 +1,5 @@ +import http from "@std/http"; + +export function foobar() { + return http.fileServer; +} |