<commit_before>#!/usr/bin/env bats

SERVER_PORT=12043

setup() {
  target/debug/zas 1>&2 &
  pid="$!"
}

teardown() {
  kill -9 "$pid" 1>&2 || true
  wait "$pid" 2>/dev/null || true
}

@test "resolves app.dev domain to 127.0.0.1" {
  response="$(dig app.dev @127.0.0.1 -p $SERVER_PORT +short +retry=0)"

  [ "$response" = "127.0.0.1" ]
}

@test "resolves anything_asdfasdf.dev to 127.0.0.1" {
  response="$(dig anything_asdfasdf.dev @127.0.0.1 -p $SERVER_PORT +nocomment +retry=0)"

  domain="$(echo "$response" | grep -v "^;" | grep "\.dev" | cut -d "	" -f 1)"
  domain="${domain%.}"
  ip="$(echo "$response" | grep -v "^;" | grep "\.dev" | cut -d "	" -f 5)"

  [ "$domain" = "anything_asdfasdf.dev" ]
  [ "$ip" = "127.0.0.1" ]
}

@test "accepts more then one request" {
  dig app.dev @127.0.0.1 -p $SERVER_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $SERVER_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $SERVER_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $SERVER_PORT +nocomment +retry=0
}

@test "does not know any other domains" {
  response="$(dig google.com @127.0.0.1 -p $SERVER_PORT +short +retry=0)"

  [ "$response" = "" ]
}<commit_msg>test: Rename variable for clarity<commit_after>#!/usr/bin/env bats

DNS_PORT=12043

setup() {
  target/debug/zas 1>&2 &
  pid="$!"
}

teardown() {
  kill -9 "$pid" 1>&2 || true
  wait "$pid" 2>/dev/null || true
}

@test "resolves app.dev domain to 127.0.0.1" {
  response="$(dig app.dev @127.0.0.1 -p $DNS_PORT +short +retry=0)"

  [ "$response" = "127.0.0.1" ]
}

@test "resolves anything_asdfasdf.dev to 127.0.0.1" {
  response="$(dig anything_asdfasdf.dev @127.0.0.1 -p $DNS_PORT +nocomment +retry=0)"

  domain="$(echo "$response" | grep -v "^;" | grep "\.dev" | cut -d "	" -f 1)"
  domain="${domain%.}"
  ip="$(echo "$response" | grep -v "^;" | grep "\.dev" | cut -d "	" -f 5)"

  [ "$domain" = "anything_asdfasdf.dev" ]
  [ "$ip" = "127.0.0.1" ]
}

@test "accepts more then one request" {
  dig app.dev @127.0.0.1 -p $DNS_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $DNS_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $DNS_PORT +nocomment +retry=0
  dig app.dev @127.0.0.1 -p $DNS_PORT +nocomment +retry=0
}

@test "does not know any other domains" {
  response="$(dig google.com @127.0.0.1 -p $DNS_PORT +short +retry=0)"

  [ "$response" = "" ]
}
{'fraction_non_alphanumeric': 0.21923076923076923, 'fraction_numerical': 0.0735042735042735, 'mean_word_length': 3.248638838475499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 22, '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': '1654207', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1025, 'n_words': 240}