<commit_before>package traffic

import (
  "testing"
  "net/http"
  "reflect"
  assert "github.com/pilu/miniassert"
)

func TestNew(t *testing.T) {
  router := New()
  assert.Type(t, "*traffic.Router", router)
  assert.Type(t, "map[traffic.HttpMethod][]*traffic.Route", router.routes)

  emptyMap := make(map[HttpMethod][]*Route)
  assert.Equal(t, emptyMap, router.routes)

  assert.Equal(t, 2, len(router.middlewares))
  assert.Type(t, "*traffic.LoggerMiddleware", router.middlewares[0])
  assert.Type(t, "*traffic.RouterMiddleware", router.middlewares[1])

  assert.Equal(t, 1, len(router.env))
  assert.Equal(t, "development", router.env["env"].(string))
}

func TestRouter_Add(t *testing.T) {
  router := New()
  assert.Equal(t, 0, len(router.routes["GET"]))
  route := router.Add(HttpMethod("GET"), "/", httpHandlerExample)
  assert.Type(t, "*traffic.Route", route)
  assert.Equal(t, 1, len(router.routes["GET"]))
}

func TestRouter_Get(t *testing.T) {
  router := New()
  assert.Equal(t, 0, len(router.routes["GET"]))
  assert.Equal(t, 0, len(router.routes["HEAD"]))
  route := router.Get("/", httpHandlerExample)
  assert.Type(t, "*traffic.Route", route)
  assert.Equal(t, 1, len(router.routes["GET"]))
  assert.Equal(t, 1, len(router.routes["HEAD"]))<commit_msg>fixed tests<commit_after>package traffic

import (
  "testing"
  "net/http"
  "reflect"
  assert "github.com/pilu/miniassert"
)

func TestNew(t *testing.T) {
  router := New()
  assert.Type(t, "*traffic.Router", router)
  assert.Type(t, "map[traffic.HttpMethod][]*traffic.Route", router.routes)

  emptyMap := make(map[HttpMethod][]*Route)
  assert.Equal(t, emptyMap, router.routes)

  assert.Equal(t, 2, len(router.middlewares))
  assert.Type(t, "*traffic.LoggerMiddleware", router.middlewares[0])
  assert.Type(t, "*traffic.RouterMiddleware", router.middlewares[1])

  assert.Equal(t, 2, len(router.env))
  assert.Equal(t, "development", router.env["env"].(string))
  assert.Type(t, "*log.Logger", router.env["logger"])
}

func TestRouter_Add(t *testing.T) {
  router := New()
  assert.Equal(t, 0, len(router.routes["GET"]))
  route := router.Add(HttpMethod("GET"), "/", httpHandlerExample)
  assert.Type(t, "*traffic.Route", route)
  assert.Equal(t, 1, len(router.routes["GET"]))
}

func TestRouter_Get(t *testing.T) {
  router := New()
  assert.Equal(t, 0, len(router.routes["GET"]))
  assert.Equal(t, 0, len(router.routes["HEAD"]))
  route := router.Get("/", httpHandlerExample)
  assert.Type(t, "*traffic.Route", route)
  assert.Equal(t, 1, len(router.routes["GET"]))
  assert.Equal(t, 1, len(router.routes["HEAD"]))
{'fraction_non_alphanumeric': 0.2006172839506173, 'fraction_numerical': 0.007716049382716049, 'mean_word_length': 5.355392156862745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1014626', 'n_tokens_mistral': 979, 'n_tokens_neox': 972, 'n_words': 161}