aboutsummaryrefslogtreecommitdiffstats
path: root/meetup
diff options
context:
space:
mode:
authorTeddy Wing2018-04-13 00:16:43 +0200
committerTeddy Wing2018-04-13 00:16:43 +0200
commit245bad9aca695cc288c7e83fdb8226cd33077520 (patch)
tree9fd3cb329f5230042814db6f19f7be2bf8b332ab /meetup
parentbd4b053dcb2dd98b145c73459a34f7771824f166 (diff)
downloadmeetup-find-events-rss-245bad9aca695cc288c7e83fdb8226cd33077520.tar.bz2
Ideas for functions to extract `Event`s from JSON
Add a couple function skeletons. Write the beginning of a test for the function that parses a JSON string to a list of `Event`s. In order to do the test, needed to derive `Debug` and `PartialEq` on `Event`.
Diffstat (limited to 'meetup')
-rw-r--r--meetup/src/event.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/meetup/src/event.rs b/meetup/src/event.rs
index aeac64c..5ca5b54 100644
--- a/meetup/src/event.rs
+++ b/meetup/src/event.rs
@@ -1,3 +1,4 @@
+#[derive(Debug, PartialEq)]
pub struct Event {
pub name: String,
pub description: String,
@@ -6,3 +7,39 @@ pub struct Event {
pub local_time: String,
// venue struct
}
+
+
+// pub fn find_upcoming_events() -> Vec<Event> {
+// }
+
+
+fn parse_json(json: String) -> Vec<Event> {
+ Vec::new()
+}
+
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_parse_json_parses_event_json() {
+ let events = parse_json(
+ include_str!("../testdata/meetup--find-upcoming_events.json")
+ .to_owned()
+ );
+
+ assert_eq!(
+ events,
+ vec![
+ Event {
+ name: "Hackspace Project Night - Open to Everyone!".to_owned(),
+ description: "<p>Spend some time on your project by bringing it along to our weekly project night, an evening designed around you and what you're working on.</p> <p>This weekly event is about finding time to tinker, being creative, and meeting other members of the community. You'll get the chance to see what others are working on, share your projects, and to get inspiration and feedback from fellow tinkerers.</p> <p>On any given Tuesday night you have people working on electronics, knitting, writing code, wood-working, or just their plans for world domination. Beer is also consumed.</p> <p>We’ll provide: space to work, basic tools, power, a room full of like minded people.</p> <p>You’ll provide: your project, ideas and beer (optional). A laptop would probably be useful too.</p> <p>Sometimes we work on group projects together, which are usually set up as separate meetup events. Keep an eye on our events page to see what we’re working on next.</p> <p>Note: We usually have around 10 or 20 people at these events, many of our members come along but aren't counted as they don't respond on meetup.</p> <p><img src=\"http://photos3.meetupstatic.com/photos/event/b/3/b/2/600_459406002.jpeg\" /></p> ".to_owned(),
+ link: "https://www.meetup.com/Cambridge-Hackspace/events/249620800/".to_owned(),
+ local_date: "2018-04-17".to_owned(),
+ local_time: "18:30".to_owned(),
+ },
+ ]
+ );
+ }
+}