Skip to content

Commit

Permalink
Merge pull request #6 from bodo-run/more-e2e
Browse files Browse the repository at this point in the history
More e2e
  • Loading branch information
mohsen1 authored Jan 17, 2025
2 parents 9a5bb3a + 85035ee commit de379a7
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
target/

# Test files
node_modules/
package-lock.json
yarn.lock
pnpm-lock.yaml
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

It uses a YAML file (`tools.yaml`) to list each tool's name, environment variables, and commands to run, making it easy for new contributors to update the logic without writing Rust code.

## Features

- Uses a centralized `tools.yaml` to define each tool's disabling strategy (commands, env vars, etc.)
- Configurable via CLI flags (planned)
- Installs easily with `curl`

## Supported Tools

Head over to [`tools.yaml`](tools.yaml) to see the list of supported tools.
Expand Down
66 changes: 66 additions & 0 deletions tests/node_e2e_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use assert_cmd::Command;
use predicates::prelude::*;
use std::error::Error;
use std::path::PathBuf;

Expand Down Expand Up @@ -34,3 +35,68 @@ fn test_nodejs_ecosystem_ignore_tools() -> Result<(), Box<dyn Error>> {

Ok(())
}

#[test]
fn test_npm_outdated_nag() -> Result<(), Box<dyn Error>> {
// Use the pre-existing nagging package
let nagging_package = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("test_files")
.join("nagging-package");

// First, ensure we're starting with a clean environment by unsetting any existing env vars
let mut reset_cmd = Command::new("npm");
reset_cmd
.env_remove("NPM_CONFIG_UPDATE_NOTIFIER")
.args(["config", "delete", "update-notifier"])
.current_dir(&nagging_package)
.assert()
.success();

// Set update-notifier to true to ensure we start in a nagging state
let mut enable_cmd = Command::new("npm");
enable_cmd
.env_remove("NPM_CONFIG_UPDATE_NOTIFIER")
.args(["config", "set", "update-notifier", "true"])
.current_dir(&nagging_package)
.assert()
.success();

// Verify update-notifier is enabled
let mut verify_cmd = Command::new("npm");
verify_cmd
.env_remove("NPM_CONFIG_UPDATE_NOTIFIER")
.args(["config", "get", "update-notifier"])
.current_dir(&nagging_package)
.assert()
.success()
.stdout(predicate::str::contains("true"));

// Run stop-nagging to set environment vars that silence the notices
let mut stop_nagging_cmd = Command::cargo_bin("stop-nagging")?;
stop_nagging_cmd
.arg("--ecosystems")
.arg("nodejs")
.assert()
.success();

// Run npm config list to verify the environment variable is set
let mut env_cmd = Command::new("npm");
env_cmd
.args(["config", "list"])
.current_dir(&nagging_package)
.assert()
.success()
.stdout(predicate::str::contains("update-notifier = false"));

// Also verify the config is set to false
let mut post_config_cmd = Command::new("npm");
post_config_cmd
.args(["config", "get", "update-notifier"])
.current_dir(&nagging_package)
.assert()
.success()
.stdout(predicate::str::contains("false"));

Ok(())
}
12 changes: 12 additions & 0 deletions tests/test_files/nagging-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "nagging-package",
"version": "1.0.0",
"dependencies": {
"left-pad": "^1.0.0",
"vercel": "^38.0.0",
"prisma": "^2.0.0"
},
"scripts": {
"start": "vercel -v && prisma -v"
}
}

0 comments on commit de379a7

Please sign in to comment.