<commit_before>package restapi

import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

type TestHelloWorldEndpoint struct{}

func (api TestHelloWorldEndpoint) HelloWorld(names []string) (string, error) {
	// handle 0-to-Many qs names
	defaultName := "World"
	name := defaultName
	if len(names) != 0 {
		name = strings.Join(names, ", ")
	}

	msg := fmt.Sprintf("Hello %s!", name)
	return msg, nil
}

func TestHelloWorldHandler(t *testing.T) {
	tests := []struct {
		description        string
		hwEndpoint         *TestHelloWorldEndpoint
		url                string
		expectedStatusCode int
		message            string
	}{
		{
			description:        "successful query",
			hwEndpoint:         &TestHelloWorldEndpoint{},
			url:                "/hw?name=DUDE",
			expectedStatusCode: 200,
			message:            "Hello DUDE!",
		},
		{
			description:        "successful query",
			hwEndpoint:         &TestHelloWorldEndpoint{},
			url:                "/hw",
			expectedStatusCode: 200,
			message:            "Hello World!",
		},
	}

	for _, hw := range tests {
		app := &RestAPI{hw: hw.hwEndpoint}
		req, err := http.NewRequest("GET", hw.url, nil)
		if err != nil {

		}

		w := httptest.NewRecorder()
		app.HelloWorldHandler(w, req)

		// TODO: travis test forcing error
		// if hw.expectedStatusCode != w.Code {
		if hw.expectedStatusCode == w.Code {
			t.Errorf("handler returned wrong status code: got %v want %v",
				w.Code, hw.expectedStatusCode)
		}

		assert.Equal(t, hw.message, w.Body.String(), hw.description)

	}
}
<commit_msg>revert force fail changes<commit_after>package restapi

import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

type TestHelloWorldEndpoint struct{}

func (api TestHelloWorldEndpoint) HelloWorld(names []string) (string, error) {
	// handle 0-to-Many qs names
	defaultName := "World"
	name := defaultName
	if len(names) != 0 {
		name = strings.Join(names, ", ")
	}

	msg := fmt.Sprintf("Hello %s!", name)
	return msg, nil
}

func TestHelloWorldHandler(t *testing.T) {
	tests := []struct {
		description        string
		hwEndpoint         *TestHelloWorldEndpoint
		url                string
		expectedStatusCode int
		message            string
	}{
		{
			description:        "successful query",
			hwEndpoint:         &TestHelloWorldEndpoint{},
			url:                "/hw?name=DUDE",
			expectedStatusCode: 200,
			message:            "Hello DUDE!",
		},
		{
			description:        "successful query",
			hwEndpoint:         &TestHelloWorldEndpoint{},
			url:                "/hw",
			expectedStatusCode: 200,
			message:            "Hello World!",
		},
	}

	for _, hw := range tests {
		app := &RestAPI{hw: hw.hwEndpoint}
		req, err := http.NewRequest("GET", hw.url, nil)
		if err != nil {

		}

		w := httptest.NewRecorder()
		app.HelloWorldHandler(w, req)

		if hw.expectedStatusCode != w.Code {
			t.Errorf("handler returned wrong status code: got %v want %v",
				w.Code, hw.expectedStatusCode)
		}

		assert.Equal(t, hw.message, w.Body.String(), hw.description)

	}
}

{'fraction_non_alphanumeric': 0.1330348576910777, 'fraction_numerical': 0.005116725295810681, 'mean_word_length': 2.688679245283019, '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': '1643413', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1022, 'n_words': 241}