Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions src/config/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ pub fn store_token(token: &str) -> Result<()> {
})
}

pub fn load_token() -> Result<String> {
let config = load_config()?;
config
.api_token
.context("No token found. Run `detail auth login`")
}

pub fn clear_credentials() -> Result<()> {
update_config(|config| {
config.api_token = None;
Expand Down Expand Up @@ -292,17 +285,11 @@ mod tests {
// ── token helpers ────────────────────────────────────────────────

#[test]
fn store_and_load_token() {
fn store_token_roundtrip() {
with_temp_config(|| {
store_token("dtl_live_secret").unwrap();
assert_eq!(load_token().unwrap(), "dtl_live_secret");
});
}

#[test]
fn load_token_errors_when_absent() {
with_temp_config(|| {
assert!(load_token().is_err());
let config = load_config().unwrap();
assert_eq!(config.api_token.as_deref(), Some("dtl_live_secret"));
});
}

Expand All @@ -311,7 +298,7 @@ mod tests {
with_temp_config(|| {
store_token("dtl_live_secret").unwrap();
clear_credentials().unwrap();
assert!(load_token().is_err());
assert!(load_config().unwrap().api_token.is_none());
});
}

Expand Down
Loading