<commit_before>package requests_test

import (
	"bytes"
	"io/ioutil"
	"net/http"
	"testing"

	"github.com/mschwager/riplink/src/requests"
)

type MockClient struct {
	Body string
	Code int
	Err  error
}

func (client MockClient) Do(request *http.Request) (response *http.Response, err error) {
	response = &http.Response{
		StatusCode: client.Code,
		Body:       ioutil.NopCloser(bytes.NewReader([]byte(client.Body))),
	}

	return response, client.Err
}

func TestDoBasic(t *testing.T) {
	body := ""
	code := 200

	client := MockClient{
		Body: body,
		Code: code,
	}

	result_body, result_code, result_err := requests.Request(client, "UNUSED", "UNUSED", nil)

	if result_body != body || result_code != code || result_err != nil {
		t.Error("Failed to parse request: ", client)
	}
}<commit_msg>Added test for error state in requests library<commit_after>package requests_test

import (
	"bytes"
	"errors"
	"io/ioutil"
	"net/http"
	"testing"

	"github.com/mschwager/riplink/src/requests"
)

type MockClient struct {
	Body string
	Code int
	Err  error
}

func (client MockClient) Do(request *http.Request) (response *http.Response, err error) {
	response = &http.Response{
		StatusCode: client.Code,
		Body:       ioutil.NopCloser(bytes.NewReader([]byte(client.Body))),
	}

	return response, client.Err
}

func TestDoBasic(t *testing.T) {
	body := ""
	code := 200

	client := MockClient{
		Body: body,
		Code: code,
	}

	result_body, result_code, result_err := requests.Request(client, "UNUSED", "UNUSED", nil)

	if result_body != body || result_code != code || result_err != nil {
		t.Error("Failed to parse request: ", client)
	}
}

func TestDoError(t *testing.T) {
	body := ""
	code := 0
	err := errors.New("")

	client := MockClient{
		Body: body,
		Code: code,
		Err:  err,
	}

	result_body, result_code, result_err := requests.Request(client, "UNUSED", "UNUSED", nil)

	if result_body != body || result_code != code || result_err != err {
		t.Error("Failed to parse request: ", client)
	}
}
{'fraction_non_alphanumeric': 0.14543630892678033, 'fraction_numerical': 0.003510531594784353, 'mean_word_length': 4.12853470437018, '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': '791650', 'n_tokens_mistral': 743, 'n_tokens_neox': 715, 'n_words': 175}