Skip to content
Snippets Groups Projects
Commit f7cb694c authored by Leonardo Christino's avatar Leonardo Christino
Browse files

add extra test for like logic

parent 9c6d7d80
No related branches found
No related tags found
No related merge requests found
Pipeline #126745 failed
......@@ -81,8 +81,8 @@ func TestV2NoLogic(t *testing.T) {
}
t.Log(*cypher)
answer := `MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
answer := `MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
RETURN * LIMIT 5000`
fmt.Printf("Cypher: %s\n", answer)
......@@ -150,7 +150,7 @@ func TestV2Simple(t *testing.T) {
}
t.Log(*cypher)
answer := `MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
answer := `MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
WHERE (p1.name <> "Raymond Campbell")
RETURN * LIMIT 5000`
......@@ -211,7 +211,7 @@ func TestV2GroupBy(t *testing.T) {
}
t.Log(*cypher)
answer := `MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
answer := `MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person))
WHERE ((movie.imdbRating < 7.500000) AND (p2.age = p1.age))
RETURN path2 LIMIT 5000`
......@@ -264,8 +264,8 @@ func TestV2NoLabel(t *testing.T) {
}
t.Log(*cypher)
answer := `MATCH path1 = ((p1)<-[acted*1..1]-(movie:Movie))
WHERE ((movie.year - p1.year) < 10.000000)
answer := `MATCH path1 = ((p1)<-[acted*1..1]-(movie:Movie))
WHERE ((movie.year - p1.year) < 10.000000)
RETURN * LIMIT 5000`
fmt.Printf("Cypher: %s\n", answer)
......@@ -322,7 +322,7 @@ func TestV2NoDepth(t *testing.T) {
t.Log(*cypher)
answer := `MATCH path1 = ((p1)<-[acted]-(movie:Movie))
answer := `MATCH path1 = ((p1)<-[acted]-(movie:Movie))
MATCH path2 = ((p2))
WHERE ((movie.imdbRating < 7.500000) AND (p2.age = p1.age))
RETURN * LIMIT 5000`
......@@ -377,7 +377,7 @@ func TestV2WithAverage(t *testing.T) {
t.Log(*cypher)
answer := `MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WITH avg(p1.age) AS p1_age_avg
WITH avg(p1.age) AS p1_age_avg
MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WHERE (p1.age < p1_age_avg)
RETURN * LIMIT 5000`
......@@ -449,7 +449,7 @@ func TestV2WithAverage2Paths(t *testing.T) {
answer := `MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WITH avg(p1.age) AS p1_age_avg
WITH avg(p1.age) AS p1_age_avg
MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WHERE (p1.age < p1_age_avg)
......@@ -494,9 +494,9 @@ func TestV2SingleEntityWithLowerLike(t *testing.T) {
}
t.Log(*cypher)
answer := `MATCH path1 = ((p1:Person))
MATCH path1 = ((p1:Person))
WHERE (toLower(p1.name) =~ (".*" + "john" + ".*"))
answer := `MATCH path1 = ((p1:Person))
MATCH path1 = ((p1:Person))
WHERE (toLower(p1.name) =~ (".*" + "john" + ".*"))
RETURN * LIMIT 5000`
fmt.Printf("Cypher: %s\n", answer)
......@@ -506,6 +506,61 @@ func TestV2SingleEntityWithLowerLike(t *testing.T) {
assert.Equal(t, trimmedAnswer, trimmedCypher)
}
func TestV2Like(t *testing.T) {
query := []byte(`{
"databaseName": "neo4j",
"query": [
{
"ID": "path_0",
"node": {
"ID": "id_1691576718400",
"label": "Employee",
"relation": {
"ID": "id_1691576720177",
"label": "REPORTS_TO",
"direction": "TO",
"node": {}
}
}
}
],
"limit": 500,
"return": [
"*"
],
"logic": [
"Like",
"@id_1691576718400.title",
"\"ale\""
]
}`)
var JSONQuery entityv2.IncomingQueryJSON
err := json.Unmarshal(query, &JSONQuery)
if err != nil {
fmt.Println(err)
t.Log(err)
}
s := NewService()
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
t.Log(err)
}
t.Log(*cypher)
answer := `MATCH path_0 = ((id_1691576718400:Employee)<-[id_1691576720177:REPORTS_TO]-())
WHERE (id_1691576718400.title =~ (".*" + "ale" + ".*"))
RETURN * LIMIT 500`
fmt.Printf("Cypher: %s\n", answer)
trimmedCypher := fixCypherSpaces(cypher)
trimmedAnswer := fixCypherSpaces(&answer)
assert.Equal(t, trimmedAnswer, trimmedCypher)
}
// func TestSmallChain(t *testing.T) {
// query := []byte(`{
// "databaseName": "TweedeKamer",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment