~qaul/community

ratman: fix broken test v1 PROPOSED

Alyssa Ross
Alyssa Ross: 2
 ratman: fix broken test
 ratman: fix broken test

 2 files changed, 16 insertions(+), 12 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~qaul/community/patches/10842/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] ratman: fix broken test Export this patch

Alyssa Ross
This seq was 2 bytes long with postcard, but with bincode it's 4 bytes
long.  I modified the test to make it so that the length was only
specified in one place, to make it easier to change back if we go back
to postcard in future.  That one check of the length is still there
though as a check that the serialization format doesn't change
unexpectedly.

I also changed some assert!s to assert_eq!s, for nicer error messages.

CC: Katharina Fey <kookie@spacekookie.de>
---
 ratman/src/core/collector/mod.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ratman/src/core/collector/mod.rs b/ratman/src/core/collector/mod.rs
index ef5a0024..e3fd60c4 100644
--- a/ratman/src/core/collector/mod.rs
+++ b/ratman/src/core/collector/mod.rs
@@ -176,7 +176,7 @@ fn queue_many() {
    
    let seqid = id;
    let len = seq.len();
    assert_eq!(len, 2);
    assert_eq!(len, 4);
    
    task::block_on(async move {
        let c = Collector::new();
@@ -186,15 +186,17 @@ fn queue_many() {
        }

        // There is n queued frames
        assert!(c.num_queued().await == 2);
        assert_eq!(c.num_queued().await, len);

        let w = c.get_worker(seqid).await;

        // We can twice three times before the worker dies
        assert!(w.poll().await == Some(()));
        assert!(w.poll().await == None);
	// There will be len - 1 items, followed by a None.
	for i in 1..len {
            assert_eq!(w.poll().await, Some(()));
	}
        assert_eq!(w.poll().await, None);

        // Now get the finished message
        assert!(c.completed().await.id == seqid);
        assert_eq!(c.completed().await.id, seqid);
    });
}
-- 
2.26.2

[PATCH v2] ratman: fix broken test Export this patch

Alyssa Ross
This seq was 2 bytes long with postcard, but with bincode it's 4 bytes
long.  I modified the test to make it so that the length was only
specified in one place, to make it easier to change back if we go back
to postcard in future.  That one check of the length is still there
though as a check that the serialization format doesn't change
unexpectedly.

I also changed some assert!s to assert_eq!s, for nicer error messages.

CC: Katharina Fey <kookie@spacekookie.de>
---
v2 fixes indentation.

 ratman/src/core/collector/mod.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ratman/src/core/collector/mod.rs b/ratman/src/core/collector/mod.rs
index ef5a0024..641c681e 100644
--- a/ratman/src/core/collector/mod.rs
+++ b/ratman/src/core/collector/mod.rs
@@ -176,7 +176,7 @@ fn queue_many() {

    let seqid = id;
    let len = seq.len();
    assert_eq!(len, 2);
    assert_eq!(len, 4);

    task::block_on(async move {
        let c = Collector::new();
@@ -186,15 +186,17 @@ fn queue_many() {
        }

        // There is n queued frames
        assert!(c.num_queued().await == 2);
        assert_eq!(c.num_queued().await, len);

        let w = c.get_worker(seqid).await;

        // We can twice three times before the worker dies
        assert!(w.poll().await == Some(()));
        assert!(w.poll().await == None);
        // There will be len - 1 items, followed by a None.
        for i in 1..len {
            assert_eq!(w.poll().await, Some(()));
        }
        assert_eq!(w.poll().await, None);

        // Now get the finished message
        assert!(c.completed().await.id == seqid);
        assert_eq!(c.completed().await.id, seqid);
    });
}
--
2.26.2