Skip to content

Commit

Permalink
chore(sync): add tests for visibility logic
Browse files Browse the repository at this point in the history
  • Loading branch information
9Lukas5 committed Apr 16, 2023
1 parent 0564954 commit eafa476
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,15 +793,51 @@ UNLISTED 🔓 ✅ Tagged people
assert!(posts.tweets.is_empty());
}

// Test that direct toots starting with "@" are not copied to twitter.
// Test that direct toots are not copied to twitter.
#[test]
fn direct_toot() {
let mut status = get_mastodon_status();
status.content = "Test Hello! http://example.com".to_string();
status.visibility = Visibility::Direct;
let tweets = Vec::new();
let statuses = vec![status];
let posts = determine_posts(&statuses, &tweets, &DEFAULT_SYNC_OPTIONS);
assert!(posts.tweets.is_empty());
}

// test that public toots are synced
#[test]
fn public_toot() {
let mut status = get_mastodon_status();
status.content = "@Test Hello! http://example.com".to_string();
status.visibility = Visibility::Public;
let tweets = Vec::new();
let statuses = vec![status];
let posts = determine_posts(&statuses, &tweets, &DEFAULT_SYNC_OPTIONS);
assert_eq!(posts.tweets.len(), 1);
}

// test that unlisted toots are synced
#[test]
fn unlisted_toot() {
let mut status = get_mastodon_status();
status.content = "Test Hello! http://example.com".to_string();
status.visibility = Visibility::Unlisted;
let tweets = Vec::new();
let statuses = vec![status];
let posts = determine_posts(&statuses, &tweets, &DEFAULT_SYNC_OPTIONS);
assert_eq!(posts.tweets.len(), 1);
}

// test that private toots are NOT synced
#[test]
fn private_toot() {
let mut status = get_mastodon_status();
status.content = "Test Hello! http://example.com".to_string();
status.visibility = Visibility::Private;
let tweets = Vec::new();
let statuses = vec![status];
let posts = determine_posts(&statuses, &tweets, &DEFAULT_SYNC_OPTIONS);
assert!(posts.toots.is_empty());
assert!(posts.tweets.is_empty());
}

Expand Down

0 comments on commit eafa476

Please sign in to comment.