From 93967f8f8fccf6e2b6b18839a284e49aaf048141 Mon Sep 17 00:00:00 2001 From: igamigo Date: Wed, 15 May 2024 21:02:29 -0300 Subject: [PATCH] fix: remove default tag (#343) --- src/store/sqlite_store/store.sql | 2 +- src/tests.rs | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/store/sqlite_store/store.sql b/src/store/sqlite_store/store.sql index a8fd81610..b2fb3fd48 100644 --- a/src/store/sqlite_store/store.sql +++ b/src/store/sqlite_store/store.sql @@ -177,7 +177,7 @@ CREATE TABLE state_sync ( -- insert initial row into state_sync table INSERT OR IGNORE INTO state_sync (block_num, tags) -SELECT 0, '[0]' +SELECT 0, '[]' WHERE ( SELECT COUNT(*) FROM state_sync ) = 0; diff --git a/src/tests.rs b/src/tests.rs index e71db3690..17cc8e421 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -326,36 +326,35 @@ async fn test_tags() { let mut client = create_test_client(); // Assert that the store gets created with the tag 0 (used for notes consumable by any account) - let tag_1: NoteTag = 0.into(); - assert_eq!(client.get_note_tags().unwrap(), vec![tag_1]); + assert_eq!(client.get_note_tags().unwrap(), vec![]); // add a tag - let tag_2: NoteTag = 1.into(); - let tag_3: NoteTag = 2.into(); + let tag_1: NoteTag = 1.into(); + let tag_2: NoteTag = 2.into(); + client.add_note_tag(tag_1).unwrap(); client.add_note_tag(tag_2).unwrap(); - client.add_note_tag(tag_3).unwrap(); // verify that the tag is being tracked - assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2, tag_3]); + assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2]); // attempt to add the same tag again client.add_note_tag(tag_1).unwrap(); // verify that the tag is still being tracked only once - assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2, tag_3]); + assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2]); // Try removing non-existent tag let tag_4: NoteTag = 4.into(); client.remove_note_tag(tag_4).unwrap(); // verify that the tracked tags are unchanged - assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2, tag_3]); + assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_2]); // remove second tag - client.remove_note_tag(tag_2).unwrap(); + client.remove_note_tag(tag_1).unwrap(); - // verify that tag_2 is not tracked anymore - assert_eq!(client.get_note_tags().unwrap(), vec![tag_1, tag_3]); + // verify that tag_1 is not tracked anymore + assert_eq!(client.get_note_tags().unwrap(), vec![tag_2]); } #[tokio::test]