<commit_before>package local_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	. "launchpad.net/gocheck"
	"net"
	"net/http"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"testing"

	"launchpad.net/juju-core/environs/local"
)

func TestLocal(t *testing.T) {
	TestingT(t)
}

type backendSuite struct{}

var _ = Suite(&backendSuite{})

const environName = "test-environ"

var testSetMu sync.Mutex

// nextTestSet returns a new port number, listener and data directory.
func nextTestSet(c *C) (int, net.Listener, string) {
	testSetMu.Lock()
	defer testSetMu.Unlock()

	dataDir := c.MkDir()
	listener, err := local.Listen(dataDir, environName, "127.0.0.1", 0)
	c.Assert(err, IsNil)
	_, ports, err := net.SplitHostPort(listener.Addr().String())
	c.Assert(err, IsNil)
	port, err := strconv.Atoi(ports)
	c.Assert(err, IsNil)

	return port, listener, dataDir
}

type testCase struct {
	name    string
	content string
	found   []string
	status  int
}

var getTests = []testCase{
	{
		// Get existing file.
		name:    "foo",
		content: "this is file 'foo'",
	},
	{
		// Get existing file.
		name:    "bar",
		content: "this is file 'bar'",
	},
	{
		// Get existing file.
		name:    "baz",
		content: "this is file 'baz'",
	},<commit_msg>environs/local: small port gathering change after review<commit_after>package local_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	. "launchpad.net/gocheck"
	"net"
	"net/http"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"testing"

	"launchpad.net/juju-core/environs/local"
)

func TestLocal(t *testing.T) {
	TestingT(t)
}

type backendSuite struct{}

var _ = Suite(&backendSuite{})

const environName = "test-environ"

var testSetMu sync.Mutex

// nextTestSet returns a new port number, listener and data directory.
func nextTestSet(c *C) (int, net.Listener, string) {
	testSetMu.Lock()
	defer testSetMu.Unlock()

	dataDir := c.MkDir()
	listener, err := local.Listen(dataDir, environName, "127.0.0.1", 0)
	c.Assert(err, IsNil)
	port := listener.Addr().(*net.TCPAddr).Port

	return port, listener, dataDir
}

type testCase struct {
	name    string
	content string
	found   []string
	status  int
}

var getTests = []testCase{
	{
		// Get existing file.
		name:    "foo",
		content: "this is file 'foo'",
	},
	{
		// Get existing file.
		name:    "bar",
		content: "this is file 'bar'",
	},
	{
		// Get existing file.
		name:    "baz",
		content: "this is file 'baz'",
	},
{'fraction_non_alphanumeric': 0.15281837160751566, 'fraction_numerical': 0.005845511482254697, 'mean_word_length': 3.598848368522073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7033705', 'n_tokens_mistral': 963, 'n_tokens_neox': 932, 'n_words': 233}