Browse Source

Test new

master
Dylan Baker 5 years ago
parent
commit
552f4252f4
1 changed files with 41 additions and 0 deletions
  1. 41
    0
      src/main.rs

+ 41
- 0
src/main.rs View File

@@ -102,3 +102,44 @@ fn main() {
102 102
         new(&matches.value_of("name").unwrap());
103 103
     }
104 104
 }
105
+
106
+mod tests {
107
+    #[allow(unused_imports)]
108
+    use super::*;
109
+    #[allow(unused_imports)]
110
+    use uuid::Uuid;
111
+
112
+    #[test]
113
+    fn test_new() {
114
+        let temp_dir = env::temp_dir();
115
+        env::set_current_dir(&temp_dir).unwrap();
116
+
117
+        let uuid = Uuid::new_v4().to_string();
118
+        let project_dir = temp_dir.join(&uuid);
119
+        new(&uuid);
120
+
121
+        for dir in &["public", "posts", "templates"] {
122
+            fs::read_dir(&project_dir.join(dir)).unwrap();
123
+        }
124
+
125
+        assert_eq!(
126
+            "",
127
+            fs::read_to_string(&project_dir.join("templates").join("post_listing.html")).unwrap()
128
+        );
129
+        assert_eq!(
130
+            "",
131
+            fs::read_to_string(&project_dir.join("templates").join("layout.html")).unwrap()
132
+        );
133
+        assert_eq!(
134
+            "",
135
+            fs::read_to_string(&project_dir.join("templates").join("post_listing_item.html"))
136
+                .unwrap()
137
+        );
138
+        assert_eq!(
139
+            "",
140
+            fs::read_to_string(&project_dir.join("templates").join("post.html")).unwrap()
141
+        );
142
+
143
+        fs::remove_dir_all(project_dir).unwrap();
144
+    }
145
+}

Loading…
Cancel
Save