✨ Backend støtter mulighet for å slette innmeldte feilmeldinger
Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no>
This commit is contained in:
		
							parent
							
								
									df3ce139c2
								
							
						
					
					
						commit
						2f58fb9df6
					
				
					 3 changed files with 18 additions and 0 deletions
				
			
		|  | @ -71,4 +71,8 @@ class FeilmeldingRepository { | ||||||
|             it[FeilmeldingTable.kommentar] = kommentar |             it[FeilmeldingTable.kommentar] = kommentar | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     fun slettFeilmelding(id: Int) = transaction { | ||||||
|  |         FeilmeldingTable.deleteWhere { FeilmeldingTable.id eq id } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -73,6 +73,12 @@ fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngin | ||||||
|                 feilmeldingRepository.oppdaterKommentar(innkommendeKommentar.id, innkommendeKommentar.kommentar) |                 feilmeldingRepository.oppdaterKommentar(innkommendeKommentar.id, innkommendeKommentar.kommentar) | ||||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding oppdatert") |                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding oppdatert") | ||||||
|             } |             } | ||||||
|  |             delete("api/slettfeilmelding/{id}") { | ||||||
|  |                 val id = call.parameters["id"] | ||||||
|  |                 checkNotNull(id) {"Id kan ikke være null"} | ||||||
|  |                 feilmeldingRepository.slettFeilmelding(id.toInt()) | ||||||
|  |                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding slettet") | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |  | ||||||
|  | @ -188,4 +188,12 @@ class FeilmeldingTest { | ||||||
|         val oppdatertKommentar = transaction { FeilmeldingTable.selectAll().single()[FeilmeldingTable.kommentar] } |         val oppdatertKommentar = transaction { FeilmeldingTable.selectAll().single()[FeilmeldingTable.kommentar] } | ||||||
|         assertEquals("Oppdatert kommentar", oppdatertKommentar) |         assertEquals("Oppdatert kommentar", oppdatertKommentar) | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     fun `Feilmelding slettes basert på id`() { | ||||||
|  |         feilmeldingRepository.lagre(feilmelding) | ||||||
|  |         feilmeldingRepository.slettFeilmelding(getId()) | ||||||
|  |         val resultat = transaction { FeilmeldingTable.selectAll().map { it }.size } | ||||||
|  |         assertEquals(0, resultat) | ||||||
|  |     } | ||||||
| } | } | ||||||
		Reference in a new issue
	
	 Amalie Mansåker
						Amalie Mansåker