<commit_before>package bad.robot.temperature.server

import bad.robot.temperature.CrcFailure
import org.http4s.dsl._
import org.specs2.mutable.Specification

import scalaz.-\/

class EitherToResponseTest extends Specification {

  "Error mappings" >> {
    -\/(CrcFailure).toHttpResponse(ko)
    -\/(CrcFailure).toHttpResponse(temperatures => {
      Ok()
    })
  }
<commit_msg>Adding toHttpResponse test<commit_after>package bad.robot.temperature.server

import java.lang.{Error => _}

import bad.robot.temperature._
import org.http4s.dsl._
import org.specs2.mutable.Specification

import scala.{Error => _}
import scalaz.{-\/, \/-}

class EitherToResponseTest extends Specification {

  val okResponse = (_: Any) => Ok()

  "Error mappings" >> {
    -\/(CrcFailure()).toHttpResponse(okResponse).run.status                    must_== InternalServerError
    -\/(SensorError("???")).toHttpResponse(okResponse).run.status              must_== InternalServerError
    -\/(UnexpectedError("???")).toHttpResponse(okResponse).run.status          must_== InternalServerError
    -\/(FailedToFindFile("???")).toHttpResponse(okResponse).run.status         must_== NotFound
    -\/(FileError(new Exception("???"))).toHttpResponse(okResponse).run.status must_== InternalServerError
  }

  "Success mapping" >> {
    \/-("Well done").toHttpResponse(okResponse).run.status must_== Ok
  }
{'fraction_non_alphanumeric': 0.15334302325581395, 'fraction_numerical': 0.0029069767441860465, 'mean_word_length': 3.797909407665505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2405887', 'n_tokens_mistral': 430, 'n_tokens_neox': 417, 'n_words': 67}