LaunchCodeLiftoffProjects / LaunchCodeLiftoffProjects/Collab-Blog
Writing a test for the /blog/update endpoint
未关闭
还没有人认领这个 Issue。
JUnit
- 主要语言
- TypeScript
- 星标
- 8
- 派生
- 20
- PR 合并指标
- 30 天内没有已合并 PR
描述
Is your feature request related to a problem? Please describe.
The /blog/update endpoint is in need of a unit test.
Describe the solution you'd like
Write a test that successfully updates already existing information inside of the database to something new.
Additional context
This is a test written inside of BlogTests.Java to test the @PostMapping /blogs endpoint.
@Test
public void postBlogs_SavesBlogToDatabase() throws Exception {
blogTestsUtil.tearDown();
Blog blog1 = new Blog("Our Very First Blog Post", "This is an actual Subheader", "An Actual Image", "This body has things we actually care about");
MockMultipartFile firstFile = new MockMultipartFile("image", "filename.txt", "text/plain", "some xml".getBytes());
MvcResult result = mockMvc.perform(multipart("/blogs").file(firstFile).param("blogData", objectMapper.writeValueAsString(blog1)))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.header").value("Our Very First Blog Post"))
.andReturn();
assertEquals(1, blogRepository.findAll().size());
blogTestsUtil.tearDown();
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 BlogTests.Java 和现有的 postBlogs_SavesBlogToDatabase 测试开始,了解测试设置和数据库清理。确认预期目标是 /blog/update,还是上下文中显示的 /blogs 端点,然后覆盖更新现有数据库信息,并验证更新后的结果及其持久性。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, spring
- 领域
- backend, database, testing
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100