<commit_before>package testing

import (
	"net/http/httptest"

	"github.com/luizbafilho/fusis/api"
	"github.com/luizbafilho/fusis/api/types"
)

type testBalancer struct {
	services []types.Service
}

type FakeFusisServer struct {
	*httptest.Server
	Balancer api.Balancer
	api      *api.ApiService
}

func NewFakeFusisServer() *FakeFusisServer {
	balancer := newTestBalancer()
	apiHandler := api.NewAPI(balancer)
	srv := httptest.NewServer(apiHandler)
	return &FakeFusisServer{
		Server:   srv,
		api:      &apiHandler,
		Balancer: balancer,
	}
}

func newTestBalancer() *testBalancer {
	return &testBalancer{}
}

func (b *testBalancer) GetServices() []types.Service {
	return b.services
}

func (b *testBalancer) AddService(srv *types.Service) error {
	for i := range b.services {
		if b.services[i].Name == srv.Name {
			return types.ErrServiceAlreadyExists
		}<commit_msg>fixing api test<commit_after>package testing

import (
	"net/http/httptest"

	"github.com/luizbafilho/fusis/api"
	"github.com/luizbafilho/fusis/api/types"
)

type testBalancer struct {
	services []types.Service
}

type FakeFusisServer struct {
	*httptest.Server
	Balancer api.Balancer
	api      *api.ApiService
}

func NewFakeFusisServer() *FakeFusisServer {
	balancer := newTestBalancer()
	apiHandler := api.NewAPI(balancer)
	srv := httptest.NewServer(apiHandler)
	return &FakeFusisServer{
		Server:   srv,
		api:      &apiHandler,
		Balancer: balancer,
	}
}

func newTestBalancer() *testBalancer {
	return &testBalancer{}
}

func (b *testBalancer) GetLeader() string {
	return "localhost:8000"
}

func (b *testBalancer) IsLeader() bool {
	return true
}

func (b *testBalancer) GetServices() []types.Service {
	return b.services
}

func (b *testBalancer) AddService(srv *types.Service) error {
	for i := range b.services {
		if b.services[i].Name == srv.Name {
			return types.ErrServiceAlreadyExists
		}
{'fraction_non_alphanumeric': 0.11974454497072912, 'fraction_numerical': 0.0021287919105907396, 'mean_word_length': 4.545722713864307, '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': '6471835', 'n_tokens_mistral': 729, 'n_tokens_neox': 706, 'n_words': 142}