@Transactional
    public void update(MemberDto memberDto, Long templateId, UpdateTemplateRequest updateTemplateRequest) {
        Member member = memberRepository.fetchById(memberDto.id());
        Category category = categoryRepository.fetchById(updateTemplateRequest.categoryId());
        validateCategoryAuthorizeMember(category, member);
        Template template = templateRepository.fetchById(templateId);
        validateTemplateAuthorizeMember(template, member);

        template.updateTemplate(updateTemplateRequest.title(), updateTemplateRequest.description(), category);
        updateSourceCodes(updateTemplateRequest, template);
        updateTags(updateTemplateRequest, template);
        validateSourceCodesCount(updateTemplateRequest, template);
    }
@Test
    @DisplayName("템플릿 수정 실패: 권한 없음")
    void updateTemplateFailWithUnauthorized() {
        // given
        MemberDto memberDto = MemberDtoFixture.getFirstMemberDto();
        Member member = memberRepository.fetchById(memberDto.id());
        CreateTemplateRequest createdTemplate = makeTemplateRequest("title");
        Template template = saveTemplate(createdTemplate, new Category("category1", member), member);
        categoryRepository.save(new Category("category2", member));

        // when
        MemberDto otherMemberDto = MemberDtoFixture.getSecondMemberDto();
        UpdateTemplateRequest updateTemplateRequest = makeUpdateTemplateRequest(2L);

        // then
        Long templateId = template.getId();
        assertThatThrownBy(() -> templateService.update(otherMemberDto, templateId, updateTemplateRequest))
                .isInstanceOf(CodeZapException.class)
                .hasMessage("해당 템플릿에 대한 권한이 없습니다.");
    }