This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create preview namespace with preexisting toml
- Loading branch information
1 parent
0f38ba3
commit 38d56ef
Showing
5 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use assert_cmd::prelude::*; | ||
use std::env; | ||
use std::process::Command; | ||
use wrangler::fixtures::{EnvConfig, Fixture, KvConfig, WranglerToml, TEST_ENV_NAME}; | ||
|
||
#[test] | ||
fn can_create_preview_namespace() { | ||
let fixture = Fixture::new(); | ||
let mut wrangler_toml = WranglerToml::javascript("test-preview-javascript"); | ||
wrangler_toml.kv_namespaces = Some(vec![KvConfig { | ||
binding: Some("BINDING"), | ||
id: Some("1234"), | ||
}]); | ||
fixture.create_wrangler_toml(wrangler_toml); | ||
preview_namespace_creation_succeeds(&fixture, None); | ||
} | ||
|
||
#[test] | ||
fn can_create_env_preview_namespace() { | ||
let script_name = "test-env-preview-javascript"; | ||
let fixture = Fixture::new(); | ||
let mut env_config = EnvConfig::default(); | ||
env_config.kv_namespaces = Some(vec![KvConfig { | ||
binding: Some("BINDING"), | ||
id: Some("1234"), | ||
}]); | ||
let wrangler_toml = WranglerToml::with_env(script_name, env_config); | ||
fixture.create_wrangler_toml(wrangler_toml); | ||
preview_namespace_creation_succeeds(&fixture, Some(TEST_ENV_NAME)); | ||
} | ||
|
||
fn preview_namespace_creation_succeeds(fixture: &Fixture, env: Option<&str>) { | ||
env::remove_var("CF_ACCOUNT_ID"); | ||
env::remove_var("CF_ZONE_ID"); | ||
let mut create_namespace = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
create_namespace.current_dir(fixture.get_path()); | ||
create_namespace | ||
.arg("kv:namespace") | ||
.arg("create") | ||
.arg("BINDING") | ||
.arg("--preview"); | ||
if let Some(env) = env { | ||
create_namespace.arg("--env").arg(env); | ||
} | ||
create_namespace.assert().success(); | ||
} |