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") }
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") }
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") }
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) }