<commit_before>package fake_bbs

import (
	"errors"
	"sync"

	"github.com/cloudfoundry-incubator/runtime-schema/models"
)

type FakeStagerBBS struct {
	FileServerGetter

	watchingForCompleted chan bool
	completedTaskChan    chan models.Task
	completedTaskErrChan chan error

	whenSettingResolving func() error
	resolvingTaskInput   struct {
		TaskToResolve models.Task
	}

	resolvedTask   models.Task
	resolveTaskErr error

	WhenDesiringTask func(models.Task) (models.Task, error)

	sync.RWMutex
}

func NewFakeStagerBBS() *FakeStagerBBS {
	return &FakeStagerBBS{
		watchingForCompleted: make(chan bool),
	}
}

func (fakeBBS *FakeStagerBBS) WatchForCompletedTask() (<-chan models.Task, chan<- bool, <-chan error) {
	completedChan := make(chan models.Task)
	completedErrChan := make(chan error)

	fakeBBS.Lock()
	fakeBBS.completedTaskChan = completedChan
	fakeBBS.completedTaskErrChan = completedErrChan
	fakeBBS.Unlock()

	fakeBBS.watchingForCompleted <- true

	return completedChan, nil, completedErrChan
}

func (fakeBBS *FakeStagerBBS) ResolvingTask(task models.Task) (models.Task, error) {
	fakeBBS.RLock()
	callback := fakeBBS.whenSettingResolving
	fakeBBS.RUnlock()

	if callback != nil {
		err := callback()
		if err != nil {
			return task, err
		}
	}

	fakeBBS.Lock()
	defer fakeBBS.Unlock()

	fakeBBS.resolvingTaskInput.TaskToResolve = task

	return task, nil
}
<commit_msg>WatchForCompletedTask provides a stop channel<commit_after>package fake_bbs

import (
	"errors"
	"sync"

	"github.com/cloudfoundry-incubator/runtime-schema/models"
)

type FakeStagerBBS struct {
	FileServerGetter

	watchingForCompleted chan bool
	completedTaskChan    chan models.Task
	completedTaskErrChan chan error

	whenSettingResolving func() error
	resolvingTaskInput   struct {
		TaskToResolve models.Task
	}

	resolvedTask   models.Task
	resolveTaskErr error

	WhenDesiringTask func(models.Task) (models.Task, error)

	sync.RWMutex
}

func NewFakeStagerBBS() *FakeStagerBBS {
	return &FakeStagerBBS{
		watchingForCompleted: make(chan bool),
	}
}

func (fakeBBS *FakeStagerBBS) WatchForCompletedTask() (<-chan models.Task, chan<- bool, <-chan error) {
	completedChan := make(chan models.Task)
	completedErrChan := make(chan error)
	doneChan := make(chan bool)

	fakeBBS.Lock()
	fakeBBS.completedTaskChan = completedChan
	fakeBBS.completedTaskErrChan = completedErrChan
	fakeBBS.Unlock()

	fakeBBS.watchingForCompleted <- true

	return completedChan, doneChan, completedErrChan
}

func (fakeBBS *FakeStagerBBS) ResolvingTask(task models.Task) (models.Task, error) {
	fakeBBS.RLock()
	callback := fakeBBS.whenSettingResolving
	fakeBBS.RUnlock()

	if callback != nil {
		err := callback()
		if err != nil {
			return task, err
		}
	}

	fakeBBS.Lock()
	defer fakeBBS.Unlock()

	fakeBBS.resolvingTaskInput.TaskToResolve = task

	return task, nil
}

{'fraction_non_alphanumeric': 0.09456598447424136, 'fraction_numerical': 0.0, 'mean_word_length': 5.00635593220339, 'pattern_counts': {'":': 0, '<': 11, '<?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': '7034879', 'n_tokens_mistral': 1041, 'n_tokens_neox': 960, 'n_words': 209}