<commit_before>package main_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httptest"
	"testing"

	dg "github.com/brimstone/go-domainglass"
)

func Test_NotBeta(*testing.T) {
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	res, err := http.Get(ts.URL + "/domain.glass")
	if err != nil {
		log.Fatal(err)
	}
	_, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_Beta(*testing.T) {
	var err error
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	// setup beta
	res, err := http.Get(ts.URL + "/beta")
	if err != nil {
		log.Fatal(err)
	}
	_, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_Domain(*testing.T) {
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	req, err := http.NewRequest("GET", ts.URL+"/domain.glass", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Cookie", "beta=true")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	res.Body.Close()
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_API(*testing.T) {
	var err error
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	// setup beta
	res, err := http.Get(ts.URL + "/api/v1/domain.glass")
	if err != nil {
		log.Fatal(err)
	}
	body, err := ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}<commit_msg>Fixing Test_API<commit_after>package main_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httptest"
	"testing"

	dg "github.com/brimstone/go-domainglass"
)

func Test_NotBeta(*testing.T) {
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	res, err := http.Get(ts.URL + "/domain.glass")
	if err != nil {
		log.Fatal(err)
	}
	_, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_Beta(*testing.T) {
	var err error
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	// setup beta
	res, err := http.Get(ts.URL + "/beta")
	if err != nil {
		log.Fatal(err)
	}
	_, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_Domain(*testing.T) {
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	req, err := http.NewRequest("GET", ts.URL+"/domain.glass", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Cookie", "beta=true")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	res.Body.Close()
	if res.StatusCode != 200 {
		log.Fatal("Status code is ", res.Status, " expected 200")
	}
}

func Test_API(*testing.T) {
	var err error
	ts := httptest.NewServer(dg.Mux)
	defer ts.Close()

	// setup beta
	res, err := http.Get(ts.URL + "/api/v1/domain.glass")
	if err != nil {
		log.Fatal(err)
	}
	body, err := ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode != 400 {
		log.Fatal("Status code is ", res.Status, " expected 400")
	}
{'fraction_non_alphanumeric': 0.18293395675043833, 'fraction_numerical': 0.014611338398597311, 'mean_word_length': 3.3439086294416245, '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': '3656725', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1435, 'n_words': 295}