<commit_before>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package instancepoller

import (
	gc "launchpad.net/gocheck"

        "launchpad.net/juju-core/instance"
	"launchpad.net/juju-core/testing/testbase"
)

type aggregateSuite struct {
	testbase.LoggingSuite
}

var _ = gc.Suite(&aggregateSuite{})

type testInstanceGetter struct {
    ids []instance.Id
    results []instanceInfoReply
}

func (i *testInstanceGetter) Instances(ids []instance.Id) ([]instance.Instance, error) {
    var results []instance.Instance
    return results, nil
}

func (s *aggregateSuite) TestLoop(c *gc.C) {
    testGetter := new(testInstanceGetter)
    aggregator := newAggregator(testGetter)

    req := &instanceInfoReq{
        reply: make(chan instanceInfoReply),
    }
    aggregator.reqc <- req
    reply :=  <-req.reply
    c.Assert(reply.err, gc.IsNil)
}
<commit_msg>Basic error, initially failing<commit_after>// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package instancepoller

import (
        "fmt"

	gc "launchpad.net/gocheck"

        "launchpad.net/juju-core/instance"
	"launchpad.net/juju-core/testing/testbase"
)

type aggregateSuite struct {
	testbase.LoggingSuite
}

var _ = gc.Suite(&aggregateSuite{})

type testInstanceGetter struct {
    ids []instance.Id
    results []instanceInfoReply
}

type testInstance struct {
    instance.Instance
}

func (i *testInstanceGetter) Instances(ids []instance.Id) ([]instance.Instance, error) {
//    var results []instance.Instance
//    results[0] = testInstance{}
    return nil, fmt.Errorf("Some error")
}

func (s *aggregateSuite) TestLoop(c *gc.C) {
    testGetter := new(testInstanceGetter)
    aggregator := newAggregator(testGetter)

    replyChan := make(chan instanceInfoReply)
    req := instanceInfoReq{
        reply: replyChan,
        instId: instance.Id("foo"),
    }
    aggregator.reqc <- req
    reply :=  <-replyChan
    c.Assert(reply.err, gc.IsNil)
}

{'fraction_non_alphanumeric': 0.11861042183622829, 'fraction_numerical': 0.005459057071960298, 'mean_word_length': 3.623853211009174, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2258838', 'n_tokens_mistral': 679, 'n_tokens_neox': 650, 'n_words': 149}