Skip to content

Commit

Permalink
Bugfix for issue #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1ff committed Nov 18, 2020
1 parent 7223a3f commit 3b77fa4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-11-18 Michael Herstine <sp1ff@pobox.com>

Bugfix for issue #1.

2020-10-22 Michael Herstine <sp1ff@pobox.com>

Preparing for publication to crates.io.
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
mpdpopm News -- history of user-visible changes -*- outline -*-

* 0.1.13 build

** Bugfixes

*** Issue 1: `get_messages` fails on repeated channels
* 0.1.12 build

Minor changes preparatory to publication on crates.io; no user-facing changes.
Expand Down
8 changes: 4 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#+DESCRIPTION: mpdpopm
#+AUTHOR: Michael Herstine
#+EMAIL: sp1ff@pobox.com
#+DATE: <2020-10-22 Thu 09:33>
#+DATE: <2020-11-18 Wed 12:53>
#+AUTODATE: t

* Introduction
Expand All @@ -16,11 +16,11 @@

* Installing

While I plan on publishing this to [[https://crates.io/][crates.io]], I have not yet done so. You can get a source tarball & install it through the usual =configure && make && make install=:
mpdpopm is [[https://crates.io/crates/mpdpopm][available]] on [[https://crates.io/][crates.io]], but you can also get a source tarball & install it through the usual =configure && make && make install=:

#+BEGIN_SRC bash
curl -L -O https://github.com/mpdpopm/archive/0.1.12.tar.gz
tar xf mpdpopm-0.1.12.tar.gz && cd mpdpopm-0.1.12
curl -L -O https://github.com/mpdpopm/archive/0.1.13.tar.gz
tar xf mpdpopm-0.1.13.tar.gz && cd mpdpopm-0.1.13
./configure && make all check
sudo make install
#+END_SRC
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([mpdpopm], [0.1.12], [sp1ff@pobox.com], [mpdpopm], [https://github.com/sp1ff/mpdpopm])
AC_INIT([mpdpopm], [0.1.13], [sp1ff@pobox.com], [mpdpopm], [https://github.com/sp1ff/mpdpopm])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([mpdpopm/Cargo.toml.in])
AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability -Wno-override gnits std-options dist-bzip2 dist-xz])
Expand Down
32 changes: 30 additions & 2 deletions mpdpopm/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,21 @@ impl IdleClient {
if line.starts_with("message: ") {
msgs.push(String::from(&line[9..]));
} else if line.starts_with("channel: ") {
m.insert(chan.clone(), msgs.clone());
match m.get_mut(&chan) {
Some(v) => v.append(&mut msgs),
None => {
m.insert(chan.clone(), msgs.clone());
}
}
chan = String::from(&line[9..]);
msgs = Vec::new();
} else if line == "OK" {
m.insert(chan.clone(), msgs.clone());
match m.get_mut(&chan) {
Some(v) => v.append(&mut msgs),
None => {
m.insert(chan.clone(), msgs.clone());
}
}
state = State::Finished;
} else {
return Err(Error::GetMessages {
Expand Down Expand Up @@ -1167,4 +1177,22 @@ OK
let val = hm.get("send-to-playlist").unwrap();
assert!(val.len() == 1);
}

/// Test issue #1
#[tokio::test]
async fn test_issue_1() {
let mock = Box::new(Mock::new(&[(
"readmessages",
"channel: playcounts
message: a
channel: playcounts
message: b
OK
",
)]));
let mut cli = IdleClient::new(mock).unwrap();
let hm = cli.get_messages().await.unwrap();
let val = hm.get("playcounts").unwrap();
assert_eq!(val.len(), 2);
}
}

0 comments on commit 3b77fa4

Please sign in to comment.