Exemplo n.º 1
0
func TestParsingNoFetcher(t *testing.T) {
	ctxParsing := &ParsingContext{
		Ctx:      context.Background(),
		Resolver: slave.NewLocalResolver(),
	}

	tt := task
	tt.ParsingConfig.DataFetcher["type"] = "AA"
	_, err := Parsing(ctxParsing, tt)
	assert.EqualError(t, err, "Fetcher AA isn't available")
}
Exemplo n.º 2
0
func TestParsingNoData(t *testing.T) {
	Register("mock", newMockFetcher)
	defer unregister("mock")

	ctxParsing := &ParsingContext{
		Ctx:      context.Background(),
		Resolver: slave.NewLocalResolver(),
	}

	tt := task
	tt.ParsingConfig.DataFetcher["type"] = "mock"
	_, err := Parsing(ctxParsing, tt)
	assert.EqualError(t, err, "No data fetcher error")
}
Exemplo n.º 3
0
func TestParsingMissingType(t *testing.T) {
	Register("mock", newMockFetcher)
	defer unregister("mock")

	ctxParsing := &ParsingContext{
		Ctx:      context.Background(),
		Resolver: slave.NewLocalResolver(),
	}

	tt := task
	tt.ParsingConfig.DataFetcher["type"] = "mock"
	tt.ParsingConfig.DataFetcher["data"] = []byte("data: 1")
	_, err := Parsing(ctxParsing, tt)
	assert.EqualError(t, err, "Missing `type` value")
}
Exemplo n.º 4
0
func main() {
	runtime.GOMAXPROCS(10)
	var err error
	logger, err = cocaine.NewLogger()
	binds := map[string]cocaine.EventHandler{
		"handleTask": handleTask,
	}

	ctxParsing = &parsing.ParsingContext{
		Ctx:      context.Background(),
		Resolver: slave.NewLocalResolver(),
	}

	Worker, err := cocaine.NewWorker()
	if err != nil {
		log.Fatal(err)
	}
	Worker.Loop(binds)
}