added echo filter for testing purposes
This commit is contained in:
parent
01f3393968
commit
d12f40fb36
2 changed files with 34 additions and 0 deletions
14
scraping.go
14
scraping.go
|
@ -76,6 +76,11 @@ func processFilters(filters []Filter, web *Web, watch *Watch, debug bool, schedu
|
||||||
getCronDebugResult(filter)
|
getCronDebugResult(filter)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if filter.Type == "echo" {
|
||||||
|
getFilterResultEcho(filter)
|
||||||
|
processedMap[filter.ID] = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
if len(filter.Parents) == 0 && !debug {
|
if len(filter.Parents) == 0 && !debug {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -221,6 +226,10 @@ func getFilterResult(filters []Filter, filter *Filter, watch *Watch, web *Web, d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case filter.Type == "echo":
|
||||||
|
{
|
||||||
|
getFilterResultEcho(filter)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
filter.log("getFilterResult called with filter.Type == '", filter.Type, "'")
|
filter.log("getFilterResult called with filter.Type == '", filter.Type, "'")
|
||||||
}
|
}
|
||||||
|
@ -895,3 +904,8 @@ func getFilterResultLua(filter *Filter) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getFilterResultEcho(filter *Filter) {
|
||||||
|
log.Println(filter.Var1)
|
||||||
|
filter.Results = append(filter.Results, filter.Var1)
|
||||||
|
}
|
||||||
|
|
|
@ -1235,3 +1235,23 @@ func TestFilterLuaLogs(t *testing.T) {
|
||||||
t.Errorf("Unexpected log message: '%s'", filter.Logs[0])
|
t.Errorf("Unexpected log message: '%s'", filter.Logs[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEchoFilter(t *testing.T) {
|
||||||
|
helloWorld := "Hello World!"
|
||||||
|
filters := []Filter{
|
||||||
|
{
|
||||||
|
ID: 0,
|
||||||
|
Name: "Echo",
|
||||||
|
Type: "echo",
|
||||||
|
Var1: helloWorld,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
filter1 := &filters[0]
|
||||||
|
connections := []FilterConnection{}
|
||||||
|
buildFilterTree(filters, connections)
|
||||||
|
processFilters(filters, nil, nil, false, nil)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(filter1.Results, []string{helloWorld}) {
|
||||||
|
t.Errorf("%s did not match %s", helloWorld, filter1.Results)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue