Skip to content

Commit

Permalink
tests: add release fixture (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored Sep 22, 2024
1 parent 85a06f3 commit aeffbdb
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 1 deletion.
183 changes: 183 additions & 0 deletions fixtures/release/released.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"action": "released",
"release": {
"url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases/176255524",
"assets_url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases/176255524/assets",
"upload_url": "https://uploads.github.com/repos/catppuccin-rfc/polybar/releases/176255524/assets{?name,label}",
"html_url": "https://github.com/catppuccin-rfc/polybar/releases/tag/v0.0.0",
"id": 176255524,
"author": {
"login": "sgoudham",
"id": 58985301,
"node_id": "MDQ6VXNlcjU4OTg1MzAx",
"avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/sgoudham",
"html_url": "https://github.com/sgoudham",
"followers_url": "https://api.github.com/users/sgoudham/followers",
"following_url": "https://api.github.com/users/sgoudham/following{/other_user}",
"gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}",
"starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions",
"organizations_url": "https://api.github.com/users/sgoudham/orgs",
"repos_url": "https://api.github.com/users/sgoudham/repos",
"events_url": "https://api.github.com/users/sgoudham/events{/privacy}",
"received_events_url": "https://api.github.com/users/sgoudham/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOIVi3Lc4KgXIk",
"tag_name": "v0.0.0",
"target_commitish": "main",
"name": "v0.0.0",
"draft": false,
"prerelease": false,
"created_at": "2022-10-30T07:26:45Z",
"published_at": "2024-09-22T01:16:39Z",
"assets": [],
"tarball_url": "https://api.github.com/repos/catppuccin-rfc/polybar/tarball/v0.0.0",
"zipball_url": "https://api.github.com/repos/catppuccin-rfc/polybar/zipball/v0.0.0",
"body": "Test release"
},
"repository": {
"id": 559462189,
"node_id": "R_kgDOIVi3LQ",
"name": "polybar",
"full_name": "catppuccin-rfc/polybar",
"private": false,
"owner": {
"login": "catppuccin-rfc",
"id": 111534585,
"node_id": "O_kgDOBqXh-Q",
"avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/catppuccin-rfc",
"html_url": "https://github.com/catppuccin-rfc",
"followers_url": "https://api.github.com/users/catppuccin-rfc/followers",
"following_url": "https://api.github.com/users/catppuccin-rfc/following{/other_user}",
"gists_url": "https://api.github.com/users/catppuccin-rfc/gists{/gist_id}",
"starred_url": "https://api.github.com/users/catppuccin-rfc/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/catppuccin-rfc/subscriptions",
"organizations_url": "https://api.github.com/users/catppuccin-rfc/orgs",
"repos_url": "https://api.github.com/users/catppuccin-rfc/repos",
"events_url": "https://api.github.com/users/catppuccin-rfc/events{/privacy}",
"received_events_url": "https://api.github.com/users/catppuccin-rfc/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/catppuccin-rfc/polybar",
"description": "Demo repository for Catppuccin cli ",
"fork": false,
"url": "https://api.github.com/repos/catppuccin-rfc/polybar",
"forks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/forks",
"keys_url": "https://api.github.com/repos/catppuccin-rfc/polybar/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/catppuccin-rfc/polybar/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/catppuccin-rfc/polybar/teams",
"hooks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/hooks",
"issue_events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/events{/number}",
"events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/events",
"assignees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/assignees{/user}",
"branches_url": "https://api.github.com/repos/catppuccin-rfc/polybar/branches{/branch}",
"tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/tags",
"blobs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/catppuccin-rfc/polybar/statuses/{sha}",
"languages_url": "https://api.github.com/repos/catppuccin-rfc/polybar/languages",
"stargazers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/stargazers",
"contributors_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contributors",
"subscribers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscribers",
"subscription_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscription",
"commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contents/{+path}",
"compare_url": "https://api.github.com/repos/catppuccin-rfc/polybar/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/catppuccin-rfc/polybar/merges",
"archive_url": "https://api.github.com/repos/catppuccin-rfc/polybar/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/catppuccin-rfc/polybar/downloads",
"issues_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues{/number}",
"pulls_url": "https://api.github.com/repos/catppuccin-rfc/polybar/pulls{/number}",
"milestones_url": "https://api.github.com/repos/catppuccin-rfc/polybar/milestones{/number}",
"notifications_url": "https://api.github.com/repos/catppuccin-rfc/polybar/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/catppuccin-rfc/polybar/labels{/name}",
"releases_url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases{/id}",
"deployments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/deployments",
"created_at": "2022-10-30T07:24:37Z",
"updated_at": "2024-09-19T21:08:02Z",
"pushed_at": "2024-09-21T23:24:09Z",
"git_url": "git://github.com/catppuccin-rfc/polybar.git",
"ssh_url": "[email protected]:catppuccin-rfc/polybar.git",
"clone_url": "https://github.com/catppuccin-rfc/polybar.git",
"svn_url": "https://github.com/catppuccin-rfc/polybar",
"homepage": null,
"size": 22,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 5,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 5,
"watchers": 0,
"default_branch": "main",
"custom_properties": {}
},
"organization": {
"login": "catppuccin-rfc",
"id": 111534585,
"node_id": "O_kgDOBqXh-Q",
"url": "https://api.github.com/orgs/catppuccin-rfc",
"repos_url": "https://api.github.com/orgs/catppuccin-rfc/repos",
"events_url": "https://api.github.com/orgs/catppuccin-rfc/events",
"hooks_url": "https://api.github.com/orgs/catppuccin-rfc/hooks",
"issues_url": "https://api.github.com/orgs/catppuccin-rfc/issues",
"members_url": "https://api.github.com/orgs/catppuccin-rfc/members{/member}",
"public_members_url": "https://api.github.com/orgs/catppuccin-rfc/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4",
"description": "Soothing pastel experiments for the high-spirited!"
},
"sender": {
"login": "sgoudham",
"id": 58985301,
"node_id": "MDQ6VXNlcjU4OTg1MzAx",
"avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/sgoudham",
"html_url": "https://github.com/sgoudham",
"followers_url": "https://api.github.com/users/sgoudham/followers",
"following_url": "https://api.github.com/users/sgoudham/following{/other_user}",
"gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}",
"starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions",
"organizations_url": "https://api.github.com/users/sgoudham/orgs",
"repos_url": "https://api.github.com/users/sgoudham/repos",
"events_url": "https://api.github.com/users/sgoudham/events{/privacy}",
"received_events_url": "https://api.github.com/users/sgoudham/received_events",
"type": "User",
"site_admin": false
}
}
18 changes: 18 additions & 0 deletions snapshots/release/released.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: src/events/release.rs
assertion_line: 71
info:
author_name_length: 8
colour_hex: "#CBA6F7"
description_length: 12
title_length: 54
---
embeds:
- author:
icon_url: "https://avatars.githubusercontent.com/u/58985301?v=4"
name: sgoudham
url: "https://github.com/sgoudham"
color: 13346551
description: Test release
title: "[catppuccin-rfc/polybar] New release published: v0.0.0"
url: "https://github.com/catppuccin-rfc/polybar/releases/tag/v0.0.0"
23 changes: 22 additions & 1 deletion src/events/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,25 @@ pub fn make_release_embed(
}

#[cfg(test)]
mod tests {}
mod tests {
use crate::{
make_embed,
tests::{embed_context, TestConfig},
};

#[test]
fn released() {
let payload = include_str!("../../fixtures/release/released.json");
let TestConfig {
event,
mut settings,
} = TestConfig::new("release", payload);

let embed = make_embed(event)
.expect("make_embed should succeed")
.expect("event fixture can be turned into an embed");

settings.set_info(&embed_context(&embed));
settings.bind(|| insta::assert_yaml_snapshot!(embed));
}
}

0 comments on commit aeffbdb

Please sign in to comment.